[11172] in Perl-Users-Digest
Perl-Users Digest, Issue: 4771 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 28 17:07:29 1999
Date: Thu, 28 Jan 99 14:00:26 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 28 Jan 1999 Volume: 8 Number: 4771
Today's topics:
1 Last Thing: Re: Sorting a file in Perl question :: <steve@NOSPAMcyber-distributors.com>
Re: Changing drives with ActiveState Perl on NT <RobLemley@nospam.com>
Re: CPAN dl only newest <Denis.Haskin@bigfoot.com>
Detecting string containing no printing chars ? ajmas@bigfoot.com
Final Xtech'99 Program now available! (MarionEll)
Re: find/replace backslash in string..? (Christian M. Aranda)
Finding/Printing system uptime in perl (Daniel)
Re: Finding/Printing system uptime in perl <dgris@moiraine.dimensional.com>
Floating point math errors eharrington@paymentech.com
Re: Floating point math errors <abey@hill.ucr.edu>
Re: Help on deleting an item in an array? scraig@my-dejanews.com
Re: Help on deleting an item in an array? (Larry Rosler)
Re: Help on deleting an item in an array? <uri@ibnets.com>
Re: Help on deleting an item in an array? <uri@ibnets.com>
Help with @array <tszeto@mindspring.com>
Re: Help with @array <uri@ibnets.com>
Re: HELP with string parsing and scoring (Larry Rosler)
Re: How do I add an attachment to an e-mail? <Denis.Haskin@bigfoot.com>
Re: How to change @INC path permenantly? (Martien Verbruggen)
installing perl (A. Nelson)
Re: Learning perl <jim.michael@gecm.com>
Limiting length of datasent from a text box <bcompson@yahoo.com>
Mail INBOX parsing script <sparker@wash.inmet.com>
NTFS directory traversal <hagerty@fidnet.com>
Out of memory <?> <berg98@us.ibm.com>
Re: Out of memory <?> <dgris@moiraine.dimensional.com>
Re: Out of memory <?> <berg98@us.ibm.com>
Re: pattern matching (Bart Lateur)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Jan 1999 21:41:59 GMT
From: "Steve Jackson" <steve@NOSPAMcyber-distributors.com>
Subject: 1 Last Thing: Re: Sorting a file in Perl question :: please help :)
Message-Id: <01be4b06$773806c0$030e4dc0@sysadmin>
I want to thank those who have helped me so far.
One last question....below is the subroutine i used and it DOES work
for what I need it to, HOWEVER, starting on the second line and continuing
to the end of the file, it puts a " " (space) before the first letter of
each line.
something like this:
1((2((33333((444
1((222((439((
2((929(jda
That one space before each line is killing the rest of the script. Now,
if anyone can help....I need al the help I can get :)
Subrouting:
sub pleasesort{
open (FILE,"all.txt");
@filelist=<FILE>;
close(FILE);
@sorted_rows = sort (@filelist);
open (workfile, ">all.txt");
print workfile "@sorted_rows";
close (ADDUSER);
print "Content-type: text/html\n\n";
print "ALL SORTED\n";
exit;
}
Thanks,
Steve
------------------------------
Date: Thu, 28 Jan 1999 15:20:19 -0600
From: "Rob Lemley" <RobLemley@nospam.com>
Subject: Re: Changing drives with ActiveState Perl on NT
Message-Id: <03usUKwS#GA.249@pet.hiwaay.net>
Phil Tomson wrote in message <78qem9$lbc$1@user1.teleport.com>...
...
>chdir('F:\somedir') won't work if I'm running the script on drive c: - the
>working directory is still going to be the one I'm in on drive c:. I
...
Perl 5 ActivePerl binary build 507, WinNT 4.0, ServicePack 3:
system('cd');
chdir 'c:\temp';
system('cd');
print "$_\n" while(<*>);
You could be hitting NT permission problems,
which is very common. Or, maybe your
syntax is different than the text in your
message. A little sample script would help!
------------------------------
Date: Thu, 28 Jan 1999 16:19:56 -0500
From: Denis Haskin <Denis.Haskin@bigfoot.com>
To: Kaare Rasmussen <kar@webline.dk>
Subject: Re: CPAN dl only newest
Message-Id: <36B0D47C.2B8CC291@bigfoot.com>
I think the autobundle command in CPAN may be what you're looking for,
although I have not used it myself.
dwh
Kaare Rasmussen wrote:
> I'm looking for a way to just download the newest version of all the
> modules at CPAN(?)
------------------------------
Date: Thu, 28 Jan 1999 20:56:03 GMT
From: ajmas@bigfoot.com
Subject: Detecting string containing no printing chars ?
Message-Id: <78qisu$tcp$1@nnrp1.dejanews.com>
Hi,
I have a perl script that returns the records from a file that contains
a certain string. Now any fields that do not contain any printing characters
or are of zero length should be replaced with ' '.
So I am looking to do something as follows:
if (string contains printing chars) {
Do this
} else {
print " ";
}
Thanks
AJ
--
http://www.bigfoot.com/~ajmas/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 28 Jan 1999 21:46:13 GMT
From: marionell@aol.com (MarionEll)
Subject: Final Xtech'99 Program now available!
Message-Id: <19990128164613.01113.00000315@ng-ch1.aol.com>
Final Program and Registration information for XTtech '99, premier XML
Developers' event, is now available on the GCA Web site:
http://www.gca.org/conf/xtech99/xtecindx.htm
Keynote speakers include:
J. Allard, Microsoft Corporation
David Siegel, author of the bestseller, "How to build killer Web sites"
Jon Bosak, Sun Microsystems
Tim Bray, Textuality. Inc.
Mansoor Zakaria, CEO, 2Bridge Software
Don't miss out!Register today!
------------------------------
Date: Thu, 28 Jan 1999 20:23:54 GMT
From: christian.aranda@iiginc.com (Christian M. Aranda)
Subject: Re: find/replace backslash in string..?
Message-Id: <78qgg0$dbe$1@news-2.news.gte.net>
On 28 Jan 1999 14:41:31 GMT, slg@cbsms1.cb.lucent.com (Sean
Gilley,0B206,,2336) wrote:
>I have a perl script running as CGI, which needs to parse a string
>entered by a user. The string can have multiple lines, as well as
>anything else the user wants to type.
>
>In the list of "anything else" can be backslashes (\).
>
>My script needs to parse the string, replacing each \ with \\, so
>that when the string gets sent to the database it appears exactly
>as the user typed it. I can't just ignore the character, as it's
>entirely possible we'll get DOS style pathnames (bleech.)
>
>I've been trying some variant of the s/// operator, but I haven't
>found anything that works. Is there a way to do this?
>
>Sean.
$test = "I'm a clown\\";
$test =~ s#\\#\\\\#;
print $test;
Christian M. Aranda
Impact Innovations Group
------------------------
Decide what you want then decide
what you'll give up for it. Me?
I'll give up sleep.
------------------------------
Date: Thu, 28 Jan 1999 20:43:02 GMT
From: daniel.mendyke@digital.com (Daniel)
Subject: Finding/Printing system uptime in perl
Message-Id: <78qic2$o6d$1@nntpd.lkg.dec.com>
What is a quick and dirty way to print system uptime
from a perl script? System is RedHat linux on an i386.
I think the system call is 'linux_get_proc_uptime' ??
Thanks
-Daniel
------------------------------
Date: 28 Jan 1999 14:03:38 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Finding/Printing system uptime in perl
Message-Id: <m3r9sfhzyt.fsf@moiraine.dimensional.com>
daniel.mendyke@digital.com (Daniel) writes:
> What is a quick and dirty way to print system uptime
> from a perl script? System is RedHat linux on an i386.
$perl -ple '' 'uptime|'
2:49pm up 21 days, 4:23, 3 users, load average: 1.98, 1.94, 1.90
$
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 28 Jan 1999 20:04:33 GMT
From: eharrington@paymentech.com
Subject: Floating point math errors
Message-Id: <78qfs9$qf7$1@nnrp1.dejanews.com>
When I run this wee perl script:
${amt} = 1.01;
while ( ${totl} < 999999 )
{
${amt} += 0.01;
${totl} += ${amt};
print "amt=${amt} totl=${totl}\n";
}
I get a section of output that looks like this:
amt=2.23 totl=198.25
amt=2.24 totl=200.49
amt=2.25 totl=202.74
amt=2.26 totl=205
amt=2.27 totl=207.27
amt=2.27999999999999 totl=209.55
amt=2.28999999999999 totl=211.84
amt=2.29999999999999 totl=214.14
Can anything be done in Perl to prevent losing molecules from these pennies?
Thanks.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 28 Jan 1999 12:20:04 -0800
From: Abraham Grief <abey@hill.ucr.edu>
To: eharrington@paymentech.com
Subject: Re: Floating point math errors
Message-Id: <Pine.LNX.4.05.9901281219300.8809-100000@hill.ucr.edu>
Read the faq.
http://language.perl.com/newdocs/pod/perlfaq4.html
On Thu, 28 Jan 1999 eharrington@paymentech.com wrote:
> When I run this wee perl script:
>
> ${amt} = 1.01;
>
> while ( ${totl} < 999999 )
> {
> ${amt} += 0.01;
> ${totl} += ${amt};
> print "amt=${amt} totl=${totl}\n";
> }
>
> I get a section of output that looks like this:
>
> amt=2.23 totl=198.25
> amt=2.24 totl=200.49
> amt=2.25 totl=202.74
> amt=2.26 totl=205
> amt=2.27 totl=207.27
> amt=2.27999999999999 totl=209.55
> amt=2.28999999999999 totl=211.84
> amt=2.29999999999999 totl=214.14
>
> Can anything be done in Perl to prevent losing molecules from these pennies?
>
> Thanks.
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
>
------------------------------
Date: Thu, 28 Jan 1999 19:18:06 GMT
From: scraig@my-dejanews.com
Subject: Re: Help on deleting an item in an array?
Message-Id: <78qd55$nr3$1@nnrp1.dejanews.com>
In article <78nfgo$kva$1@starburst.uk.insnet.net>,
"Chris Denman" <c-denman@dircon.co.uk> wrote:
>
> $fred[6] needs to be completely erased, and all others shifted down.
>
Use array slices with the range operator. The special variable $#arrayname
contains the index of the last element of @arrayname.
@fred[6..$#fred] = @fred[7..$#fred]; # leaves 1..5 same, last becomes undef
$#fred --; # shortens array removing last (undef)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 28 Jan 1999 13:25:05 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help on deleting an item in an array?
Message-Id: <MPG.111a758c41a4d03c9899db@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <78qd55$nr3$1@nnrp1.dejanews.com> on Thu, 28 Jan 1999
19:18:06 GMT, scraig@my-dejanews.com <scraig@my-dejanews.com> says...
> In article <78nfgo$kva$1@starburst.uk.insnet.net>,
> "Chris Denman" <c-denman@dircon.co.uk> wrote:
>
> > $fred[6] needs to be completely erased, and all others shifted down.
>
> Use array slices with the range operator. The special variable $#arrayname
> contains the index of the last element of @arrayname.
>
> @fred[6..$#fred] = @fred[7..$#fred]; # leaves 1..5 same, last becomes undef
> $#fred --; # shortens array removing last (undef)
Good Lord. Don't even *think* of doing that!
#!/usr/local/bin/perl -w
use Benchmark;
my @a = (0 .. 99);
timethese(1 << (shift || 0), {
Cntrl => sub { @fred = @a },
Slice => sub { @fred = @a;
@fred[6..$#fred] = @fred[7..$#fred]; $#fred --; },
Splice => sub { @fred = @a; splice @fred, 6, 1 },
});
Benchmark: timing 32768 iterations of Cntrl, Slice, Splice...
Cntrl: 5 wallclock secs ( 4.66 usr + 0.00 sys = 4.66 CPU)
Slice: 19 wallclock secs (19.03 usr + 0.00 sys = 19.03 CPU)
Splice: 5 wallclock secs ( 4.77 usr + 0.00 sys = 4.77 CPU)
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 28 Jan 1999 16:11:27 -0500
From: Uri Guttman <uri@ibnets.com>
To: scraig@my-dejanews.com
Subject: Re: Help on deleting an item in an array?
Message-Id: <39btjjumps.fsf@ibnets.com>
>>>>> "s" == scraig <scraig@my-dejanews.com> writes:
>> $fred[6] needs to be completely erased, and all others shifted down.
>>
s> Use array slices with the range operator. The special variable
s> $#arrayname contains the index of the last element of @arrayname.
s> @fred[6..$#fred] = @fred[7..$#fred]; # leaves 1..5 same, last
s> becomes undef
s> $#fred --; # shortens array removing last (undef) p
that is absurd code. it may work but it is very confusing. use splice as
a previous poster said.
here is a great case of perl making life easier with builtin operations
vs. the long way around.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: 28 Jan 1999 16:45:13 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Help on deleting an item in an array?
Message-Id: <394spbul5i.fsf@ibnets.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
>> @fred[6..$#fred] = @fred[7..$#fred]; # leaves 1..5 same, last
>> becomes undef $#fred --; # shortens array removing last (undef)
LR> Good Lord. Don't even *think* of doing that!
i don't know who got more repulsed, you or i!! i followed up as fast as
i could.
LR> timethese(1 << (shift || 0), {
LR> Cntrl => sub { @fred = @a },
LR> Slice => sub { @fred = @a;
LR> @fred[6..$#fred] = @fred[7..$#fred]; $#fred --; },
LR> Splice => sub { @fred = @a; splice @fred, 6, 1 },
LR> });
LR> Cntrl: 5 wallclock secs ( 4.66 usr + 0.00 sys = 4.66 CPU)
LR> Slice: 19 wallclock secs (19.03 usr + 0.00 sys = 19.03 CPU)
LR> Splice: 5 wallclock secs ( 4.77 usr + 0.00 sys = 4.77 CPU)
it is amazing how close splice is to control! assuming that it really
only used .11 seconds more, the it is about 130 [ (19.03-4.77)/.11 ]
times faster than the slice code. this is probably close to a record for
slow dumb code.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 28 Jan 1999 13:01:48 +0000
From: tszeto <tszeto@mindspring.com>
Subject: Help with @array
Message-Id: <36B05FB6.C71FE14C@mindspring.com>
Hi,
I can't figure out why I can't print to screen an element of this array.
I can print the whole array, but when I try to just print out $array[0],
nothing comes up.
Any help appreciated.
Regards,
Ted
The script fragment is as follows and I try to print in the last two
lines.
open (infile, "file");
$line = <infile>;
chomp $line;
###### beginning of product loop ############
$count= 0;
while ($line ne "*** BILLING INFO: ***") {
if ($line =~ /SKUID: /) {
$skuid = $line;
$skuid =~ s/SKUID: //;
$skuid =~ s/ //g;
@item_array[$count] = $skuid;
$line = <infile>;
}
if ($line =~ /QUANTITY: /) {
$quantity = $line;
$quantity =~ s/QUANTITY: //;
$quantity =~ s/ //g;
@item_array[$count + 1] = $quantity;
}
$count++;
$line = <infile>;
chomp $line;
}
###### end of product loop ############
print @item_array, "\n";
print $iem_array[0];
------------------------------
Date: 28 Jan 1999 16:15:01 -0500
From: Uri Guttman <uri@ibnets.com>
Subject: Re: Help with @array
Message-Id: <3990enumju.fsf@ibnets.com>
>>>>> "t" == tszeto <tszeto@mindspring.com> writes:
t> $count= 0;
t> while ($line ne "*** BILLING INFO: ***") {
t> if ($line =~ /SKUID: /) {
t> $line = <infile>;
t> }
t> if ($line =~ /QUANTITY: /) {
t> @item_array[$count + 1] = $quantity;
t> }
t> $count++;
how come you are only incrementing $count by 1, but you assign to $count
and $count + 1 slots?
use push instead as you don't need count then
t> print @item_array, "\n";
t> print $iem_array[0];
^^^
does the spelling look funy to you here?
use -w and those problems will show up.
uri
--
Uri Guttman Hacking Perl for Ironbridge Networks
uri@sysarch.com uri@ironbridgenetworks.com
------------------------------
Date: Thu, 28 Jan 1999 13:34:27 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: HELP with string parsing and scoring
Message-Id: <MPG.111a77be9b5910289899dc@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36B0B3FF.64BCE4B7@atrieva.com> on Thu, 28 Jan 1999 11:01:19
-0800, Jerome O'Neil <jeromeo@atrieva.com> says...
...
> I have posted a clean warning version that is still faster than using
> split. Split is an expensive function compared to substr, even if you
> have to convolute the methods for your offsets.
Gosh, Jerome. By now, *three* of us have shown you the error of your
ways, and (as is well known) what I tell you three times is true. :-)
Maybe you should own up, to set the record straight. Split is indeed
faster than a loop on substr, as well as being a lot easier to get right
(as your serial corrections have dempnstrated).
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 28 Jan 1999 15:49:25 -0500
From: Denis Haskin <Denis.Haskin@bigfoot.com>
To: Vasco =?iso-8859-1?Q?Patr=EDcio?= <vpatricio@abrantina.pt>
Subject: Re: How do I add an attachment to an e-mail?
Message-Id: <36B0CD55.A894EFF5@bigfoot.com>
I've had good experiences using the MIME::Lite module to do just as you
describe. You can find it easily in CPAN.
dwh
"Vasco Patrmcio" wrote:
> This would work fine, except that I don4t want the '$tmpfile' to be sent in
> the body of the message. Instead, I'd rather send it on an attachment,
> which I don't know how to do.
------------------------------
Date: Thu, 28 Jan 1999 21:52:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to change @INC path permenantly?
Message-Id: <5_4s2.17$LH2.1784@nsw.nnrp.telstra.net>
In article <36AFCE81.4581565B@snailgem.org>,
Eugene Sotirescu <eugene@snailgem.org> writes:
> Note that none of these modify @INC permanently. I don't know that this
> can be done without recompiling Perl.
Edit your Config.pm file, which you should be able to find in your architecture directory.
for 5.004 versions:
${PERL_LIB}/${ARCH}/${VERSION}/Config.pm
for 5.005 versions
${PERL_LIB}/${VERSION}/${ARCH}/Config.pm
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing down
Interactive Media Division | all the noises the baby makes so later
Commercial Dynamics Pty. Ltd. | I can ask him what he meant - Steven
NSW, Australia | Wright
------------------------------
Date: 28 Jan 1999 19:58:05 GMT
From: mbane@s-crim1.dl.ac.uk (A. Nelson)
Subject: installing perl
Message-Id: <78qfgd$6ad$1@mserv2.dl.ac.uk>
Hello All,
I am trying to install perl 5.005_02 on my solaris 2.7 box, the
problem is even though I successfully run Configure and make depend
when it runs make it comes up with the following error:
Current working directory /usr/local/perl5.005_02/x2p
echo Makefile.SH cflags.SH | tr ' ' '\n' >.shlist
Updating makefile...
gcc -o miniperl miniperlmain.o libperl.a
Undefined first referenced
symbol in file
log libperl.a(pp.o)
pow libperl.a(pp.o)
sqrt libperl.a(pp.o)
floor libperl.a(pp.o)
atan2 libperl.a(pp.o)
exp libperl.a(pp.o)
sin libperl.a(pp.o)
cos libperl.a(pp.o)
ld: fatal: Symbol referencing errors. No output written to miniperl
*** Error code 1
make: Fatal error: Command failed for target `miniperl'
I don't know why this happens and how to solve this problem.
Thanks for any help you can render.
A Nelson
a.nelson@icr.ac.uk
London
------------------------------
Date: Thu, 28 Jan 1999 13:33:04 -0500
From: Jim Michael <jim.michael@gecm.com>
Subject: Re: Learning perl
Message-Id: <36B0AD60.27CC@gecm.com>
Eric Gorely wrote:
> This works, but I can't, for the life of me, figure out how to get the
> numbers formatted according to the second part of the exercise. Can anyone
perldoc -f sprintf
------------------------------
Date: 28 Jan 1999 21:21:38 GMT
From: "Quentin Compson" <bcompson@yahoo.com>
Subject: Limiting length of datasent from a text box
Message-Id: <01be4b03$d9f13000$0d20440c@brmptrue>
Hello
How can I go about making sure someone doesn't send my script
too much data in a text box?
Should I test for length?
------------------------------
Date: Thu, 28 Jan 1999 21:39:13 GMT
From: Steven Parker <sparker@wash.inmet.com>
Subject: Mail INBOX parsing script
Message-Id: <36B0D901.D0DB4997@wash.inmet.com>
I am interested in writing a script (or finding) that will parse the
ASCII
INBOX mail file.
I don't know how to handle attachments. How would you take the part of
the
file that corresponds to the attachment (say, a .exe file) and create
the
corresponding .exe file?
Is there any code that anyone knows of that would give me hints (e.g.,
emacs's mail parsing code)
Any help here would be much appreciated!
Thanks,
Steve
------------------------------
Date: Thu, 28 Jan 1999 09:41:46 -0600
From: Jason Hagerty <hagerty@fidnet.com>
Subject: NTFS directory traversal
Message-Id: <36B0853A.332A4CD7@fidnet.com>
To who it may concern
I am new to writting perl, but I'm having a problem traversing a the
NTFS directory tree. Actually the problem arises when I try to print
out only files of a certain type while traversing the directory tree. I
have include the code I am using.
Thanks.
#!/usr/bin/perl
&dodir('.');
sub dodir
{ local($dir,$nlink) = @_;
local($dev,$ino,$mode,$subcount);
($dev,$ino,$mode,$nlink) = stat('.') unless $nlink;
opendir(DIR, '.') || die "Can't open $dir";
local(@filenames) = readdir(DIR);
closedir(DIR);
if($nlink == 2)
{ for(@filenames)
{ next if (/^\.\.?$/);
print "$dir/$_\n";
}
}
else
{ $subcount = $nlink - 2;
for(@filenames)
{ next if (/^\.\.?$/);
$name = "$dir/$_";
if (/\.exe$/)
{
print $name,"\n";
}
next if $subcount == 0;
($dev,$ino,$mode,$nlink) = lstat($_);
next unless -d;
chdir $_ || die "Can't cd to $name";
&dodir($name,$nlink);
chdir '..';
--$subcount;
}
}
}
------------------------------
Date: Thu, 28 Jan 1999 15:43:13 -0500
From: "Shawn A. Berg" <berg98@us.ibm.com>
Subject: Out of memory <?>
Message-Id: <36B0CBE1.FC3B6C08@us.ibm.com>
Is the entire file read into memory when the angle operator is used
here? Any suggestions for other methods to do this?
Code:
$SFILE = &uncompress(\$file);
open SFILE or die "Can't open $SFILE";
print "ho\n";
foreach (<SFILE>) {
print "ho ho\n";
.
.
.
}
Output:
ho
Out of memory!
File:
-rw-r--r-- * * * 112166849 Jan 28 14:44 19990102.csv
------------------------------
Date: 28 Jan 1999 13:57:43 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Out of memory <?>
Message-Id: <m3vhhri08o.fsf@moiraine.dimensional.com>
"Shawn A. Berg" <berg98@us.ibm.com> writes:
> Is the entire file read into memory when the angle operator is used
> here?
Yes, but not because of the <>, it's because of for(). for(), map(),
and grep() all construct the lists they iterate over before beginning
the first loop.
> Any suggestions for other methods to do this?
Use a while() loop instead.
while ($line = <SFILE>) {
do_stuff($line);
}
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 28 Jan 1999 16:06:15 -0500
From: "Shawn A. Berg" <berg98@us.ibm.com>
Subject: Re: Out of memory <?>
Message-Id: <36B0D146.4EDC0E40@us.ibm.com>
I changed it to a while loop, and that seems to work. I'm not clear on
why though.
"Shawn A. Berg" wrote:
> Is the entire file read into memory when the angle operator is used
> here? Any suggestions for other methods to do this?
>
> Code:
>
> $SFILE = &uncompress(\$file);
> open SFILE or die "Can't open $SFILE";
> print "ho\n";
> foreach (<SFILE>) {
> print "ho ho\n";
> .
> #do stuff with $_.
> .
> }
>
> Output:
>
> ho
> Out of memory!
>
> File:
> -rw-r--r-- * * * 112166849 Jan 28 14:44 19990102.csv
------------------------------
Date: Thu, 28 Jan 1999 20:20:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: pattern matching
Message-Id: <36b2c194.2819574@news.skynet.be>
Tyler Hutcheon wrote:
> I have quite a bit of experience with perl, but I'm about to write a
>script where I need some help with pattern matching, and I don't know all
>that much about it.
>
>I know the basics, how to execute it, etc, but what I don't know is what all
>the fancy symbols represent and how to mark fields to output to variables,
>like $1, $2, etc. I also need to know what the \-commands do, like \s+ and
>\S+, etc. And what the brackets, + symbols, and *'s do to affect the match.
>
>I've looked pattern matching in perlfaq4 but I still don't understand it.
I've looked at <http://reference.perl.com/query.cgi?section=regexp>, but
the link to "Perl Tutorial: String matching" no longer works. Damn.
Anyway, I think you should come back here once you get a bit of
experience with them. TomC's "all about" article and the PDF file from
"Effective Perl Programming" (with only 2 m's) are ddefinitely worth a
look.
I've done a bit of searching, and I think this could serve as a
reasonable practical introduction:
"Regular Expressions Give Perl its Luster" by Ben Smith
http://webreview.com/wr/pub/97/07/04/perl/index.html
Bart.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4771
**************************************