[22633] in Perl-Users-Digest
Perl-Users Digest, Issue: 4854 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 16 14:10:49 2003
Date: Wed, 16 Apr 2003 11:10:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 16 Apr 2003 Volume: 10 Number: 4854
Today's topics:
Remembering previous values of the form. <shah@typhoon.xnet.com>
Re: Remote Module Installation (Vijoy Varghese)
Re: slow/inefficient script: seeking help with multimat <nobull@mail.com>
Re: Stumped! <delautenschl@[nospam]wisc.edu>
Re: Syntax problem <tzz@lifelogs.com>
Trouble with Variable Interpolation while executing a d (Liberty Belle)
Re: Trouble with Variable Interpolation while executing <nobull@mail.com>
Re: Trouble with Variable Interpolation while executing <stevenm@bogus.blackwater-pacific.com>
Re: Unlink Not Working On Windows Server (Tad McClellan)
Why is this expression so slow?? (Sara)
Re: Why is this expression so slow?? <uri@stemsystems.com>
Re: Why is this expression so slow?? <sgt19@tid.es>
Re: Why is this expression so slow?? <sgt19@tid.es>
Re: Why is this expression so slow?? <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Apr 2003 17:58:26 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Remembering previous values of the form.
Message-Id: <b7k5k2$9of$1@flood.xnet.com>
Folks,
I am writing timesheet entry system using perl CGI.pm and Javascript,
on Linux.
I have completed the form that displays time already entered, and allows
the user to add/chage/delete time. My problem is trying to remember what
the timesheet looked like when it was displayed, so that I can somehow
compare it with the new values when user presses "Save" button.
The time sheet grid looks similar to:
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
|Contract|Project|Task|Description | Mon | Tue | Wed | Thu | Fri | Sat | Sun |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
| | | | | | | | | | | |
+--------+-------+----+------------+-----+-----+-----+-----+-----+-----+-----+
+------+ +------+ +------+
| Prev | | Next | | Save |
+------+ +------+ +------+
When I display the grid, it may have few entries previously entered. I want to
store current values. When user presses "Save" button, I would like to compare
it with previous values so that I would know which entries were Added/Removed/
Changed. I could then run SQL statementsto update the database.
How can I do it? Preferably without using files. Ther are 2 options I am
thinking about.
1) When building the HTML form, perl script would Write the existing values to
a file on the server, and add hidden variables to the HTML form. When
the user updates the entries in the form, the javascript would update
the values of the hidden variables. When user presses "Save" button,
another perl script would be executed. The second perl script would
retrieve the hidden variables using param() and compare it with the
previous values stored in the file.
2) When building the HTML form, perl script would add hidden variables to the
HTML form. When the user updates the entries in the form, the javascript
would generate psuedo SQL code based on the changes made by the user.
When user presses "Save" button, another perl script would be executed.
The second perl script would retrieve the hidden variable using param()
and build SQL statement and execute it.
I started with option 1, but I am not sure if it is the best way of doing
it, I do not like to store state in the file on the server, what happens if
it gets deleted?
I am not sure how to implement option 2?
Is there another (better) way?
Thanks in advance.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: 16 Apr 2003 10:58:28 -0700
From: viijv@thedifferenZ.com (Vijoy Varghese)
Subject: Re: Remote Module Installation
Message-Id: <4c08aaff.0304160958.439e73e7@posting.google.com>
> It looks like it is a strictly-perl module, so you don't need to worry
> about compiling. Just get the .pm file onto the server and find a way
> to use pathtomodule.pm.
I added this line
use lib "/home/thediffe/public_html/project/modules";
and put
-HMAC.pm
-HMAC_MD5.pm
-HMAC_SHA1.pm
-MD2.pm
-MD4.pm
-MD5.pm
-SHA1.pm
files under /public_html/project/modules/Digest folder
and i am getting this error... :-(
Wed Apr 16 13:50:43 2003] [error] [client 202.88.224.211] Premature
end of script headers: /home/thediffe/public_html/project/temp.cgi
BEGIN failed--compilation aborted at
/home/thediffe/public_html/project/modules/Digest/HMAC_MD5.pm line 5.
first 10 lines of HMAC_MD5.pm is
package Digest::HMAC_MD5;
$VERSION="1.01";
use strict;
use Digest::MD5 qw(md5);
use Digest::HMAC qw(hmac);
# OO interface
use vars qw(@ISA);
@ISA=qw(Digest::HMAC);
Now what? :-(
Vijoy~
------------------------------
Date: 16 Apr 2003 18:43:58 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: slow/inefficient script: seeking help with multimatch/multipass pattern matching
Message-Id: <u9znmq8hi9.fsf@wcl-l.bham.ac.uk>
pls@post.here (Adam) writes:
> The script I have below works (yipee!) but is 3 times slower than
> egrep and awk in a loop :(
I can't see anything particularly inefficient in the implementation of
your script. The algorithm is inefficient, but I can't see why it
would be significantly worse in Perl than the same algorithm
implementated in egrep/awk.
Using package variables rather than lexicals is slightly slower but I
doubt it's all that significant.
However using implicit variable declaration does make maintainance
much harder. Indeed I can see many things in your code that are
non-Perlish but none that would account for the slowness.
> ====================================
> #!/usr/local/bin/perl -w
In recent Perl -w is better replaced wiht 'use warnings;'
Always 'use strict;'
>
> $maillog="/tmp/mail";
There is good no reason to use a package variable. Maybe you just
forgot. 'use strict' would have pointed this out for you.
> if ( $#ARGV == 2 ) {
$#ARGV == 2 is more idomatically wrtten as @ARGV == 3
> $name = $ARGV[0];
> $month = $ARGV[1];
> $day = $ARGV[2];
There is good no reason to use package variables. Maybe you just
forgot. 'use strict' would have pointed this out for you.
The above is more idomatically written as:
( $name,$month,$day) = @ARGV;
> }
> elsif ( $#ARGV == 1 ) {
> $name = $ARGV[0];
> $month = $ARGV[1];
> $day = 0;
> }
> elsif ( $#ARGV == 0 ) {
> $name = $ARGV[0];
> ($month, $day ) = (split( /\s+/, scalar(localtime)))[ 1, 2 ];
Converting the localtime into a string and then back into it's
components is obfuscation.
($month, $day ) = (localtime)[ 4, 3 ];
$month++;
> }
> else {
> print "Usage: $0 name [Month] [Day]\n";
> exit;
> }
>
> if ($day == 0 ) { $date = $month . " " ; }
> if ($day > 9 ) { $date = $month . " " . "$day"; }
> if ($day <= 9 ) { $date = $month . " " . "$day"; }
Perl does have sprintf().
> open(LOG,$maillog) || die "cannot open $maillog: $!";
> while ( my $match = <LOG> )
> {
> next unless ($match =~ /$date.*?]: (\w+)?: (from|to).*?$name/i );
Surely you mean /(\w+?)/ not /(\w+)?/ !
> push(@mailids,$1);
> } # end of while my match = <LOG>
There is good no reason to use a package variable for @mailids. Maybe
you just forgot. 'use strict' would have pointed this out for you.
This is the last time I'll mention this.
Perl has a wonderful variable $_ that is "the default thing".
while ( <LOG> )
{
next unless /$date.*?]: (\w+?): (from|to).*?$name/i;
push(@mailids,$1);
}
> @mailpats = map { qr/\b$_\b/i } @mailids;
You probably meant:
my @mailpats = map { qr/\b\Q$_\E\b/i } @mailids;
But better still, rather than making a list of patterns @mailpats from
a list of strings @mailids just have a hash %mailids in the first place.
Change:
push(@mailids, $1);
To:
$mailids{$1} = 1;
> open(LOG,$maillog) || die "cannot open $maillog: $!";
> while ( my $match = <LOG> ) {
> next unless /$date.*?]: \w+?: (from|to)/i ;
> for $patobj (@mailpats) {
> if ($match =~ /$patobj/) {
Now rather than looping through all those ID...
while ( <LOG> ) {
next unless /$date.*?]: (\w+?): (from|to)/i && $mailids{$1};
> if ($match =~ /from=</ ) {
> $match =~ m/(\w+?\s+\d+?\s+) # $1 Month Day
> \d+?:\d+?:\d+?\s+ # Timestamp HH:MM:SS
> \w+?\s+sm-mta-\w+? # server MTA
> \[\d+?\]:\s+? # process ID
> (\w+)?:\s+? # $2 sendmail mailq or log id
> from=<(.*)>.*? # $3 capture the name
> \s+relay=(.*?\s+?\S+?) # $4 catch relay names
> \s+(.*)/ix; # ignore the rest for now
Once again I'd get rid of $match and just use $_.
> $fromline = "$1 $2 from=$3 relay=$4\n";
> $hashkey = $2 . "frm";
> $logline_hash{$hashkey} = $fromline;
No need for all those variables:
$logline_hash{"${2}frm"} = "$1 $2 from=$3 relay=$4";
>
> elsif ($match =~ /to=</ ) {
> $match =~ m/(\w+?\s+\d+?\s+) # $1 Month Day
> \d+?:\d+?:\d+?\s+ # Timestamp HH:MM:SS
> \w+?\s+sm-mta-\w+? # server MTA
> \[\d+?\]:\s+? # process ID
> (\w+)?:\s+? # $2 sendmail mailq or log id
> to=<(.*)>.*? # $3 capture multiples names
> relay=(.*?)\s+.*? # $4 catch relay name
> \s+stat=(.*?\s+?\S+?) # $5 stat (OK) or other 2nd arg
> \s+.*/ix; #
> $toline = "$1 $2 to=$3 relay=$4 stat=$5\n";
> $hashkey = $2 . "to";
> $logline_hash{$hashkey} = $toline;
> } # end if match to
> } # end if match =~ /$patobj/
> } # end for $patobj (@mailpats)
> } # end while
>
> print "\nExtract by name\n=====================\n";
> foreach(sort keys %logline_hash) {
> $tmpvar = $_;
> chomp($tmpvar);
Why do you copy $_ into $tmpvar then chomp($tmpvar), which does
nothing becuase the keys of %logline_hash don't contain EOLs then not
do anything with $tmpvar anyhow?
> print "$logline_hash{$_}";
Why do you have double quotes in there?
Perhaps because you really want to say..
print "$logline_hash{$_}\n";
... rather than appending "\n" when you create the entries in %logline_hash.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 16 Apr 2003 12:39:21 -0500
From: Daniel Lautenschleger <delautenschl@[nospam]wisc.edu>
Subject: Re: Stumped!
Message-Id: <b7k4g8$5bu$1@news.doit.wisc.edu>
I should have been a little clearer.
I've already got unique elements for each key. There are no duplicates.
I need to get rid of each "subset" item. I need unique "items" only.
For instance:
If the following elements are:
(1,2,3,4,5)
(2,3,4,5,6,7)
(10,11,12,13)
The unique items from each element would be
1,2,3,4,5,6,7,10,11,12,13
-Dan
Steven Kuo wrote:
> On Thu, 3 Apr 2003, pooba53 wrote:
>
>
>>I have a hash that has multiple values associated with a single key.
>>i.e.:
>>
>>key is "CG2349"
>>
>>values associate with "CG2349" are :
>>
>>(1,2,3,4,5)
>>(2,3,4,5,6,7)
>>(10,11,12,13)
>>
>>Since I have multiple values associated with a single key, I'm using
>>references.
>
>
>
>
> So I imagine that you have a hash structure similar to this:
>
> my %hash = (
> CG2349 => [ [1,2,3,4,5], [2,3,4,5,6,7], [10,11,12,13] ],
> );
>
>
>
>>I'm trying to get each value (the three above) into a single array so I
>>can extract unique elements from the "merge".
>>
>>The problem I'm having is how to do this and create a new hash with one
>>value associated with each key after merging and "uniquing".
>>
>>I'm pretty sure I need to use the each function such as:
>>
>>while (($key, $value) = each(${@MyArray}) {
>>
>
>
>
>
> each expects a hash, not a scalar.
>
> You may want to try something like this:
>
> #! /usr/local/bin/perl
> use strict;
> use warnings;
>
> my %hash = (
> CG2349 => [ [1,2,3,4,5], [2,3,4,5,6,7], [10,11,12,13] ],
> );
>
> while (my ($key,$aref) = each %hash) {
> my %seen;
> my @unique = grep !$seen{$_}++, map @$_, @$aref;
> print "unique elements for $key : @unique\n";
> }
>
>
> See also
>
> % perldoc -q 'remove duplicate elements'
>
------------------------------
Date: Wed, 16 Apr 2003 11:27:55 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Syntax problem
Message-Id: <4nllya1mys.fsf@lockgroove.bwh.harvard.edu>
On Wed, 16 Apr 2003, kasp@epatra.com wrote:
> print $x for($x=0;$x<10;$x++); ###Error
Uri explained why this won't work, but also remember that Perl makes
this sort of for loop unnecessary sometimes:
print foreach (0..9);
The code above also looks cleaner.
Ted
------------------------------
Date: 16 Apr 2003 08:44:46 -0700
From: libertybelle2112@yahoo.com (Liberty Belle)
Subject: Trouble with Variable Interpolation while executing a dbi string handle
Message-Id: <d9cbd61e.0304160744.8630d2@posting.google.com>
Working on a quick little script to load some data off of a page of
text. These pages have a column header(variable name) and some wanted
information, as well as some garbage. I want to keep this script as
general as possible since there are at least 3, and more coming
variations.
Everytime it recognizes a column header, it collects it and appends it
to a var, $columnheads, as well as a comma. Additionally, I append a
', ?' to $columnqmks, so that the number of ? is equal to the number
of columns. When it finds information, it does likewise to another
var, $inputdata. So far, so good. If I print this, I get exactly
what I want. So, head over to DB angle.
My DB Handle works fine, no prob there
This part works fine as well. For the one I test, it interpolates
properly, which I know when I get the execute error
$sth_loadstmt = $dbh->prepare(qq{ INSERT INTO BalSheet (
$columnheads ) VALUES ($columnqmks) }) || die "Problem sth
loadstmt\n";
This is the problem.
$sth_loadstmt->execute($inputdata);
The execute fails because I have only 1 bind variable, when 137 (from
above) are needed. The value of $inputdata is what I want for these
137 values, separated by commas. How can I get the execute statement
to see this, rather than the single var?
Thanks a bundle!
Valerie
------------------------------
Date: 16 Apr 2003 17:54:34 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Trouble with Variable Interpolation while executing a dbi string handle
Message-Id: <u9iste9yd1.fsf@wcl-l.bham.ac.uk>
libertybelle2112@yahoo.com (Liberty Belle) writes:
> Subject: Trouble with Variable Interpolation while executing a dbi string handle
Your problem has nothing to do with variable interpolation or DBI.
You need to think logically about your problem and try to narrow it down.
> This is the problem.
>
> $sth_loadstmt->execute($inputdata);
>
> The execute fails because I have only 1 bind variable, when 137 (from
> above) are needed. The value of $inputdata is what I want for these
> 137 values, separated by commas. How can I get the execute statement
> to see this, rather than the single var?
So you have a function that wants an argument list with 137 elements
and you have a single string containing comma 137 comma separated
values.
So what you want is a way to split a delimited string into a list.
Use the split function.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 16 Apr 2003 09:52:28 -0700
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: Trouble with Variable Interpolation while executing a dbi string handle
Message-Id: <b7k1f1$co9$1@quark.scn.rain.com>
Liberty Belle wrote:
> Working on a quick little script to load some data off of a page of
> text. These pages have a column header(variable name) and some wanted
> information, as well as some garbage. I want to keep this script as
> general as possible since there are at least 3, and more coming
> variations.
>
> Everytime it recognizes a column header, it collects it and appends it
> to a var, $columnheads, as well as a comma. Additionally, I append a
> ', ?' to $columnqmks, so that the number of ? is equal to the number
> of columns. When it finds information, it does likewise to another
> var, $inputdata.
Is the above a typo? If you feed a scalar to the prepared query instead
of a list it will break when there is more than one placeholder...
So far, so good. If I print this, I get exactly
> what I want. So, head over to DB angle.
>
> My DB Handle works fine, no prob there
>
> This part works fine as well. For the one I test, it interpolates
> properly, which I know when I get the execute error
>
> $sth_loadstmt = $dbh->prepare(qq{ INSERT INTO BalSheet (
> $columnheads ) VALUES ($columnqmks) }) || die "Problem sth
> loadstmt\n";
>
> This is the problem.
>
> $sth_loadstmt->execute($inputdata);
$sth_loadstmt->execute(@inputdata);
s.
------------------------------
Date: Wed, 16 Apr 2003 09:40:32 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Unlink Not Working On Windows Server
Message-Id: <slrnb9qqr0.4n9.tadmc@magna.augustmail.com>
George <geo@divergentweb.NO.SPAM.com> wrote:
> unlink($delPath$filename);
There is a syntax error there by the way...
You could have found that by testing from the command line with:
perl -cw someprog.cgi
You probably want one of these instead:
unlink( "$delPath$filename" ) or die ...
or
unlink( "$delPath/$filename" ) or die ...
or
unlink( $delPath . $filename ) or die ...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Apr 2003 06:28:00 -0700
From: genericax@hotmail.com (Sara)
Subject: Why is this expression so slow??
Message-Id: <776e0325.0304160528.31b311ab@posting.google.com>
perl 5.8.0 on RH8 *. Running this expression on an array of about 30
elements:
map s/[\s\i\r\n]*$/\n/, @text;
*never* completes- I have to "X" out of the telnet session to recover.
"top" indicates that this line consumes 90% + CPU indefnintely..
I changed the line to:
s/[\s\i\r\n]*$/\n/ for @text;
and it DID complete correctly- in 26 clock seconds for the 30 line
file!! Like one second per line. Grrrrr...
Is 5.8.n out for any n>0? I can't tell, my browser can't reach cpan or
perl.org today, and the redhat site doesn't seem to have anything > 0.
For now I'm going to move all of the code to the Solaris box running
5.6.1, where these lines run instantly..
Fun fun fun..
Thanks,
Gx
* - I tried to "downgrade" my Perl to 5.6.1 on this box but ran into a
gaggle of failed dependencies...
------------------------------
Date: Wed, 16 Apr 2003 15:49:36 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why is this expression so slow??
Message-Id: <x7el42l9ww.fsf@mail.sysarch.com>
>>>>> "S" == Sara <genericax@hotmail.com> writes:
S> perl 5.8.0 on RH8 *. Running this expression on an array of about 30
S> elements:
S> map s/[\s\i\r\n]*$/\n/, @text;
first, what is \i? do you mean \t?
secondly, \s has \t, \n, and \r inside it already.
so you don't need a char class but a single \s will do.
thirdly, notice the *. that means it will match 0 times before the end
of the string. since you only care if it has white space, use + instead
of *.
fourthly, map in a void context is not cool.
S> *never* completes- I have to "X" out of the telnet session to recover.
S> "top" indicates that this line consumes 90% + CPU indefnintely..
and i don't see an infinite loop on 5.6.1 on my box.
S> I changed the line to:
S> s/[\s\i\r\n]*$/\n/ for @text;
that is better than map in a void context.
S> and it DID complete correctly- in 26 clock seconds for the 30 line
S> file!! Like one second per line. Grrrrr...
still very slow which is odd. there might be something else going on.
could be an actual bug with 5.8 but i can't test that.
S> For now I'm going to move all of the code to the Solaris box running
S> 5.6.1, where these lines run instantly..
which is what i have.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 16 Apr 2003 17:54:31 +0200
From: Stephane Titard <sgt19@tid.es>
Subject: Re: Why is this expression so slow??
Message-Id: <3E9D7CB6.5DFAB688@tid.es>
This is a multi-part message in MIME format.
--------------A6B0B443267750CA439B314F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sara wrote:
> perl 5.8.0 on RH8 *. Running this expression on an array of about 30
> elements:
>
> map s/[\s\i\r\n]*$/\n/, @text;
I usually use the block form of map especially if i need to modify
$_ as does your subst. e. g
perl -e '@a = ("aa", "ax"); print join "\n", map {(my $a = $_) =~ s/a/X/}
@a'
your example does not work on my perl 5.6.1 HP-UX 10.20
> *never* completes- I have to "X" out of the telnet session to recover.
> "top" indicates that this line consumes 90% + CPU indefnintely..
>
> I changed the line to:
>
>
> s/[\s\i\r\n]*$/\n/ for @text;
>
> and it DID complete correctly- in 26 clock seconds for the 30 line
> file!! Like one second per line. Grrrrr...
>
> Is 5.8.n out for any n>0? I can't tell, my browser can't reach cpan or
> perl.org today, and the redhat site doesn't seem to have anything > 0.
>
> For now I'm going to move all of the code to the Solaris box running
> 5.6.1, where these lines run instantly..
>
> Fun fun fun..
>
> Thanks,
> Gx
>
> * - I tried to "downgrade" my Perl to 5.6.1 on this box but ran into a
> gaggle of failed dependencies...
--------------A6B0B443267750CA439B314F
Content-Type: text/x-vcard; charset=us-ascii;
name="sgt19.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Stephane Titard
Content-Disposition: attachment;
filename="sgt19.vcf"
begin:vcard
n:Titard;Stephane G.
tel;cell:+34 630545970
tel;fax:+34 913374222
tel;work:+34 913379083, +34 913374786
x-mozilla-html:FALSE
org:Telefonica I+D
adr:;;Emilio Vargas 6;Madrid;;28043;Spain
version:2.1
email;internet:sgt19@tid.es
note:Despacho S 324 (sotano oeste)
x-mozilla-cpt:;2048
fn:Stephane G. Titard
end:vcard
--------------A6B0B443267750CA439B314F--
------------------------------
Date: Wed, 16 Apr 2003 18:08:00 +0200
From: Stephane Titard <sgt19@tid.es>
Subject: Re: Why is this expression so slow??
Message-Id: <3E9D7FDF.A1E4CEC6@tid.es>
This is a multi-part message in MIME format.
--------------E73C7CFBCF50D8F5DB651F66
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sara wrote:
> perl 5.8.0 on RH8 *. Running this expression on an array of about 30
> elements:
>
> map s/[\s\i\r\n]*$/\n/, @text;
>
> *never* completes- I have to "X" out of the telnet session to recover.
> "top" indicates that this line consumes 90% + CPU indefnintely..
>
> I changed the line to:
>
>
> s/[\s\i\r\n]*$/\n/ for @text;
>
> and it DID complete correctly- in 26 clock seconds for the 30 line
> file!! Like one second per line. Grrrrr...
>
> Is 5.8.n out for any n>0? I can't tell, my browser can't reach cpan or
> perl.org today, and the redhat site doesn't seem to have anything > 0.
>
> For now I'm going to move all of the code to the Solaris box running
> 5.6.1, where these lines run instantly..
>
> Fun fun fun..
>
> Thanks,
> Gx
>
> * - I tried to "downgrade" my Perl to 5.6.1 on this box but ran into a
> gaggle of failed dependencies...
Actually Uri makes a good point about your strange regex
this might be what you need:
perl -e '@a = ("aa ") x 3; print join "\n", map do{ s!\s+!X!; $_}, @a'
notice the $_ as the last expr in the do.
bye
Steph
--------------E73C7CFBCF50D8F5DB651F66
Content-Type: text/x-vcard; charset=us-ascii;
name="sgt19.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Stephane Titard
Content-Disposition: attachment;
filename="sgt19.vcf"
begin:vcard
n:Titard;Stephane G.
tel;cell:+34 630545970
tel;fax:+34 913374222
tel;work:+34 913379083, +34 913374786
x-mozilla-html:FALSE
org:Telefonica I+D
adr:;;Emilio Vargas 6;Madrid;;28043;Spain
version:2.1
email;internet:sgt19@tid.es
note:Despacho S 324 (sotano oeste)
x-mozilla-cpt:;2048
fn:Stephane G. Titard
end:vcard
--------------E73C7CFBCF50D8F5DB651F66--
------------------------------
Date: Wed, 16 Apr 2003 17:53:56 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Why is this expression so slow??
Message-Id: <x7llyajplf.fsf@mail.sysarch.com>
>>>>> "ST" == Stephane Titard <sgt19@tid.es> writes:
don't use vcards. they died out thankfully. you must be the last person
who still has them enabled. they show up as attachments and those are
not nice on usenet.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 4854
***************************************