[9707] in Perl-Users-Digest
Resend: Perl-Users Digest, Issue: 3300 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 1 19:47:13 1998
Date: Sat, 1 Aug 98 16:39:05 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 1 Aug 1998 Volume: 8 Number: 3300
Today's topics:
Re: Interesting Question needs Quick Answer (P.L. Hegarty)
Re: Interesting Question needs Quick Answer (I.J. Garlick)
Re: Interesting Question needs Quick Answer (Mike Stok)
Re: Interesting Question needs Quick Answer <upsetter@ziplink.net>
Re: Interesting Question needs Quick Answer <jdporter@min.net>
Re: Interesting Question needs Quick Answer (Mark-Jason Dominus)
Re: Interesting Question needs Quick Answer (Tim Gim Yee)
Is there a way to.. <jpratt@command-central.nmsd.k12.nm.us>
Re: Is there a way to.. (Steve Linberg)
List files by creation date? <curt@vphos.net>
Re: List files by creation date? (Tad McClellan)
luser is spelt L-O-S-E-R was Re: hiding user input <sp@m.block>
Re: luser is spelt L-O-S-E-R was Re: hiding user input (Gary L. Burnore)
Re: luser is spelt L-O-S-E-R was Re: hiding user input (Andre L.)
Mail::Pop3Client; Can not retrieve Body ;( <MSchmidt@riedlingen.netsurf.de>
Mail::Pop3Client; Can not retrieve Body ;( <MSchmidt@riedlingen.netsurf.de>
Mail::Pop3Client; Can not retrieve Body ;( <MSchmidt@riedlingen.netsurf.de>
Mail::Pop3Client; Can not retrieve Body ;( <MSchmidt@riedlingen.netsurf.de>
Mail::Pop3Client; Can not retrieve Body ;( <MSchmidt@riedlingen.netsurf.de>
Re: Memory Safe Hashes (Tye McQueen)
Re: Memory Safe Hashes (Ilya Zakharevich)
Newbie Perl Problem <loucksw@bright.net>
Re: Newbie Perl Problem <mmacdonald@del.net>
Re: newbie split question <maierc@chesco.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 30 Jul 1998 13:16:37 GMT
From: sm8plh@csc.liv.ac.uk (P.L. Hegarty)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <Ewwsvq.5Mw@csc.liv.ac.uk>
Ok if anyone else has any suggestions for a solution to this problem and you
can ignore Ian, then please send me them as so far everyone has misread the
question.
The problem is I need a script that will output to the screen an exact copy
of itself. The output should look the same as if you used 'cat or 'type' on
the script. The only restrictions are you CAN NOT read ANYTHING into the
script and you can not use any system calls, that is call more or anything
like that.
Again any help will be greatfully received.
--
Have Fun!!!
Shadolin
******************************************************************************
Patrick Hegarty shadolin@cableinet.co.uk
102 Jubilee Drive sm8plh@csc.liv.ac.uk
Liverpool shadolin@mudhole.spodnet.uk.com
L7 8SN http://www.csc.liv.ac.uk/~sm8plh/
http://wkweb4.cableinet.co.uk/shadolin/
Tel 0151 281 4510 Fax 0151 281 7123
*****************************************************************************
------------------------------
Date: Fri, 31 Jul 1998 17:38:18 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <Ewyznu.Fnr@csc.liv.ac.uk>
In article <6pqd5c$c3l5@mascagni.pfizer.com>,
jack_h_ostroff@groton.pfizer.com (Jack Ostroff) writes:
> It took a while, but I have a solution in 26 lines, including
> -w and use strict. My biggest problem was quoting quotes.
>
> I'll be glad to post it - but not until someone can assure me that
> it is too late for someone to use it as a homework solution.
>
> For those who didn't quite understand the wording of the problem:
> 'cat self.pl' and 'perl self.pl' should produce identical output
> or 'perl self.pl | diff self.pl -' should produce no output.
It's Ok he has been shown the solution now.
However do feel free to post yours as it took 49 lines here.
--
--
Ian J. Garlick
ijg@csc.liv.ac.uk
It's a damn poor mind that can only think of one way to spell a word.
-- Andrew Jackson
------------------------------
Date: 31 Jul 1998 20:17:15 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <6pt8ob$ish@news-central.tiac.net>
In article <6pqd5c$c3l5@mascagni.pfizer.com>,
Jack Ostroff <jack_h_ostroff@groton.pfizer.com> wrote:
>It took a while, but I have a solution in 26 lines, including
>-w and use strict. My biggest problem was quoting quotes.
>
>I'll be glad to post it - but not until someone can assure me that
>it is too late for someone to use it as a homework solution.
>
>For those who didn't quite understand the wording of the problem:
>'cat self.pl' and 'perl self.pl' should produce identical output
>or 'perl self.pl | diff self.pl -' should produce no output.
26 lines?
#!/usr/local/bin/perl -w
use strict;
seek DATA, 0, 0;
print while <DATA>;
__END__
Anyone setting a problem like this might be smart enough to use DejaNews
to check on their students...
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 30 Jul 1998 17:03:03 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <6pq907$kp4@fridge.shore.net>
John Porter <jdporter@min.net> wrote:
: P.L. Hegarty wrote:
:>
:> Ok if anyone else has any suggestions for a solution to this problem and you
:> can ignore Ian,
: With ethics like that, you'll make a great MicroSoft employee some day.
Writing high-quality software, no doubt! :)
--Art
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Thu, 30 Jul 1998 15:59:45 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <35C09912.5A7E@min.net>
P.L. Hegarty wrote:
>
> Ok if anyone else has any suggestions for a solution to this problem and you
> can ignore Ian,
With ethics like that, you'll make a great MicroSoft employee some day.
I suppose you buy your research papers too.
--
John Porter
------------------------------
Date: 1 Aug 1998 13:20:22 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <6pviom$d7u$1@monet.op.net>
In article <6pt8ob$ish@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:
>26 lines?
>
>#!/usr/local/bin/perl -w
>use strict;
>seek DATA, 0, 0;
>print while <DATA>;
>__END__
The original problem specification prohibited `system call's, and I
suspect that this was expressly to prevent solutions liked yours that
explictly read the program's source file.
------------------------------
Date: Sat, 01 Aug 1998 03:03:55 GMT
From: tgy@chocobo.org (Tim Gim Yee)
Subject: Re: Interesting Question needs Quick Answer
Message-Id: <35c58544.69962873@news.oz.net>
On Fri, 31 Jul 1998 17:38:18 GMT, ijg@csc.liv.ac.uk (I.J. Garlick)
wrote:
>In article <6pqd5c$c3l5@mascagni.pfizer.com>,
>jack_h_ostroff@groton.pfizer.com (Jack Ostroff) writes:
>> It took a while, but I have a solution in 26 lines, including
>> -w and use strict. My biggest problem was quoting quotes.
>>
>> I'll be glad to post it - but not until someone can assure me that
>> it is too late for someone to use it as a homework solution.
>>
>> For those who didn't quite understand the wording of the problem:
>> 'cat self.pl' and 'perl self.pl' should produce identical output
>> or 'perl self.pl | diff self.pl -' should produce no output.
>
>It's Ok he has been shown the solution now.
>
>However do feel free to post yours as it took 49 lines here.
perl -we 'seek DATA, 0, 0 and print <DATA> __DATA__'
--
Tim Gim Yee
http://www.dragonfire.net/~tgy/moogle/
"Kupo! Round and round you go! Moogle!"
------------------------------
Date: Thu, 30 Jul 1998 13:25:55 -0700
From: "J. Pratt" <jpratt@command-central.nmsd.k12.nm.us>
Subject: Is there a way to..
Message-Id: <35C0D6D3.CBBC30E5@command-central.nmsd.k12.nm.us>
Hey all..
I was hoping someone would be able to answer a question for me. I
checked Lincoln Stein's book on CGI.pm but found no answer; so pls don't
waste time telling me to RTFM (unless the answer lies within a man page
I am oblivious to:)..
What I'm wondering is how I can do something like.. If a checkbox's
checked value is 1 (On) do blah blah. This is what's going on -- I've
got a plain text file which is going to have corresponding checkboxes
for each line. Once done coding the script, the user should be able to
delete one of the lines by checking the line to delete. They'll then
submit, and the lines that were checked will be removed from the file.
For the most part, I know what to do. But.. Here's what I've got.
Notice my if (param($i) == 1) line. Apparently that won't work.. I
think the way to do this is to open the file with the contents. Then
read the contents of the file to a test array.. Next, the array will be
read and the lines checked are removed from the array. Then the array
is rewrote. Err.. Something along these lines. Any help is mucho
appreciated!
- JP
--SNIP--
#!/usr/bin/perl
use CGI ':standard';
open (A, "~/feh");
open (TMP_A, "~/feh.tmp");
$i = 0;
@what = <A>;
close (A);
print header;
print start_form;
if (param('action') eq 'Process') {
process();
} else {
for (@what) {
print checkbox(-name=>"$i",-checked=>0),"$_","<br>";
$i++; }
print submit(-name=>'action',-value=>'Process');
}
end_form;
sub process {
if (param('$i') == 1) {
print "test." }
}
------------------------------
Date: Thu, 30 Jul 1998 16:08:52 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Is there a way to..
Message-Id: <linberg-3007981608520001@projdirc.literacy.upenn.edu>
In article <35C0D6D3.CBBC30E5@command-central.nmsd.k12.nm.us>, "J. Pratt"
<jpratt@command-central.nmsd.k12.nm.us> wrote:
> Hey all..
>
> I was hoping someone would be able to answer a question for me. I
> checked Lincoln Stein's book on CGI.pm but found no answer; so pls don't
> waste time telling me to RTFM (unless the answer lies within a man page
> I am oblivious to:)..
Well, that is a book about the indispensible CGI.pm. What you have is a
general (pretty simple) programming question.
> What I'm wondering is how I can do something like.. If a checkbox's
> checked value is 1 (On) do blah blah.
<snip>
Of course you can. Parse the form's variables and do whatever you want.
If you have a linear sequence of checkboxes corresponding to lines in a
text file, then read the file into an array of lines, delete the line
whose array element corresponds to each variable the user checked, and
rewrite the file. Right?
_____________________________________________________________________
Steve Linberg National Center on Adult Literacy
Systems Programmer &c. University of Pennsylvania
linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: Thu, 30 Jul 1998 10:23:23 -0700
From: Curt Cranfield <curt@vphos.net>
Subject: List files by creation date?
Message-Id: <35C0AC0B.3E5F55EE@vphos.net>
Hi
I have checked the FAQ and O'Reilly's Perl5 book and can't quite figure
out how to do this. Can anyone lend some hints.
I am trying to figure out how to do a listing of files in a directory by
time (ie. a standard ls -ltr). Here is the chunck of code:
#!/usr/local/bin/perl -w
$newpath = "/tmp/";
opendir MYDIR, "$path" or die "Can't open $path: $!\n";
open (MYDIR,"ls -ltr |") || die "Can't list: $!\n";
@allfiles = readdir MYDIR;
#DEBUG
foreach $element (@allfiles) {
print "$element \n";
}
closedir MYDIR;
$newpath = $newpath . pop(@allfiles); #should path to newest
file!
This gives me a directory listing but in an order which doesn't make
sense. I have tried a bunch of other options but with no luck. Any
ideas?
Thanks in Advance.
Curt
------------------------------
Date: Thu, 30 Jul 1998 13:50:04 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: List files by creation date?
Message-Id: <s8fqp6.4r8.ln@localhost>
Curt Cranfield (curt@vphos.net) wrote:
: I have checked the FAQ and O'Reilly's Perl5 book and can't quite figure
: out how to do this. Can anyone lend some hints.
: I am trying to figure out how to do a listing of files in a directory by
: time (ie. a standard ls -ltr). Here is the chunck of code:
: #!/usr/local/bin/perl -w
: $newpath = "/tmp/";
: opendir MYDIR, "$path" or die "Can't open $path: $!\n";
Delete the line above.
: open (MYDIR,"ls -ltr |") || die "Can't list: $!\n";
: @allfiles = readdir MYDIR;
Change the line above to:
@allfiles = <MYDIR>;
The 'perlfunc' man page says:
=item opendir DIRHANDLE,EXPR
=item open FILEHANDLE,EXPR
Notice the difference in the first argument for each of those functions?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 02 Aug 1998 00:23:43 +0900
From: Spam Block <sp@m.block>
Subject: luser is spelt L-O-S-E-R was Re: hiding user input
Message-Id: <35C33300.88432BBD@m.block>
passme
Abigail wrote:
>
> John Call (johnc@interactive.ibm.com) wrote on MDCCXCIV September
> MCMXCIII in <URL: news:35C0855E.82D3256E@interactive.ibm.com>:
> ++
> ++
> ++ I thought once the "Perl Studs" got their .moderated group that any advic
> ++ gave here would be a little less venomous. I guess not. You got the new group
> ++ be rude in there. If you give advice here then take the Tom P.'s approach ple
>
> Lines of 80 characters, and repeatedly posting the same posting.
> That must make you luser first class, doesn't?
>
> Abigail
There are certain names that keep cropping up noteworthy for their total lack
of tolerance for their fellow beings seemingly caused by spending too much
time infront of their bedroom mirror as a Perl guru - go join PERL moderated
if you can't handle having to deal with the lesser geniuses in this world.
BTW luser is spelt L-O-S-E-R - I suggest you learn the language you speak and
stop messing with the digital stuff it's making you anti-social.
+`+`+`+SLSLDM+NFDIHDi printf "what do you mean I'm showing off"
------------------------------
Date: Sat, 01 Aug 1998 15:47:26 GMT
From: gburnore@databasix.com (Gary L. Burnore)
Subject: Re: luser is spelt L-O-S-E-R was Re: hiding user input
Message-Id: <35c837ef.133202438@nntpd.databasix.com>
On Sun, 02 Aug 1998 00:23:43 +0900, in article <35C33300.88432BBD@m.block>,
Spam Block <sp@m.block> wrote:
>passme
>
>Abigail wrote:
>>
>> John Call (johnc@interactive.ibm.com) wrote on MDCCXCIV September
>> MCMXCIII in <URL: news:35C0855E.82D3256E@interactive.ibm.com>:
>> ++
>> ++
>> ++ I thought once the "Perl Studs" got their .moderated group that any advic
>> ++ gave here would be a little less venomous. I guess not. You got the new group
>> ++ be rude in there. If you give advice here then take the Tom P.'s approach ple
>>
>> Lines of 80 characters, and repeatedly posting the same posting.
>> That must make you luser first class, doesn't?
>>
>> Abigail
>
>There are certain names that keep cropping up noteworthy for their total lack
>of tolerance for their fellow beings seemingly caused by spending too much
>time infront of their bedroom mirror as a Perl guru - go join PERL moderated
>if you can't handle having to deal with the lesser geniuses in this world.
Exactly, but it DOES need to be mentioned that many of the experts in this
group are helpful and friendly in their replies to questions. There are
really only a few jerks who make it bad for everyone else.
>
>BTW luser is spelt L-O-S-E-R - I suggest you learn the language you speak and
>stop messing with the digital stuff it's making you anti-social.
>
Two points: luser is commonly known as the way to type loser user and spell
flames are lame. (Nearly as lame as taking USENet discussions to email without
the prior permission of the recipient of said mail.>
--
for i in databasix primenet ; do ; gburnore@$i ; done
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
DOH! | ][3:]3^3:]33][:]3^3:]3]3^3:]3]][3
| ][3 3 4 1 4 2 ]3^3 6 9 0 6 9 ][3
spamgard(tm): zamboni | Official Proof of Purchase
===========================================================================
------------------------------
Date: Sat, 01 Aug 1998 12:43:10 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: luser is spelt L-O-S-E-R was Re: hiding user input
Message-Id: <alecler-0108981243100001@dialup-798.hip.cam.org>
In article <35C33300.88432BBD@m.block>, sp@m.block wrote:
> BTW luser is spelt L-O-S-E-R
No it's not. Can't you read?
Andre
------------------------------
Date: Fri, 31 Jul 1998 18:54:52 +0200
From: Michael Schmidt-Maier <MSchmidt@riedlingen.netsurf.de>
Subject: Mail::Pop3Client; Can not retrieve Body ;(
Message-Id: <35C1F6DC.595A7F56@riedlingen.netsurf.de>
Hi there all you Guru4s ;)
I finally come to the conclusion that I need your professional help with
this.
I am trying to retrieve Emails via the browser and use
thMail::Pop3Client modul. Everything works fine with retrievin headers
and subjects but I am not able to get the Body Text.
In the script below I get the "Juhu" Part but can4t see the body.
If I print the Body in the "If"-Part it displays fine, just the elsif
does not do what I want.
Any hints?
I send many thank yous in advance
Michael
#############Script fragment follows##################################
if ($submit eq 'Abfragen') {
for ($i = 1; $i <= $pop->Count; $i++) {
foreach ($pop->Head($i)) {
/^(Subject): / and print $_, "<br>\n";
/^(From): / and print "<input type=\"submit\" value=\"$i\"
name=submit>" . $_, "\<br\>\n";
}
print "<br>\n";
}
}
elsif ($submit =~ /(\d)/) {
print $pop->Body($1), "\n";
print "juhu\n";
}
else {
print "Pooh\n";
}
------------------------------
Date: Fri, 31 Jul 1998 18:49:42 +0200
From: Michael Schmidt-Maier <MSchmidt@riedlingen.netsurf.de>
Subject: Mail::Pop3Client; Can not retrieve Body ;(
Message-Id: <35C1F5A6.A8D00FAA@riedlingen.netsurf.de>
Hi there all you Guru4s ;)
I finally come to the conclusion that I need your professional help with
this.
I am trying to retrieve Emails via the browser and use
thMail::Pop3Client modul. Everything works fine with retrievin headers
and subjects but I am not able to get the Body Text.
In the script below I get the "Juhu" Part but can4t see the body.
If I print the Body in the "If"-Part it displays fine, just the elsif
does not do what I want.
Any hints?
I send many thank yous in advance
Michael
#############Script fragment follows##################################
if ($submit eq 'Abfragen') {
for ($i = 1; $i <= $pop->Count; $i++) {
foreach ($pop->Head($i)) {
/^(Subject): / and print $_, "<br>\n";
/^(From): / and print "<input type=\"submit\" value=\"$i\"
name=submit>" . $_, "\<br\>\n";
}
print "<br>\n";
}
}
elsif ($submit =~ /(\d)/) {
print $pop->Body($1), "\n";
print "juhu\n";
}
else {
print "Pooh\n";
}
------------------------------
Date: Fri, 31 Jul 1998 18:52:42 +0200
From: Michael Schmidt-Maier <MSchmidt@riedlingen.netsurf.de>
Subject: Mail::Pop3Client; Can not retrieve Body ;(
Message-Id: <35C1F65A.D573D429@riedlingen.netsurf.de>
Hi there all you Guru4s ;)
I finally come to the conclusion that I need your professional help with
this.
I am trying to retrieve Emails via the browser and use
thMail::Pop3Client modul. Everything works fine with retrievin headers
and subjects but I am not able to get the Body Text.
In the script below I get the "Juhu" Part but can4t see the body.
If I print the Body in the "If"-Part it displays fine, just the elsif
does not do what I want.
Any hints?
I send many thank yous in advance
Michael
#############Script fragment follows##################################
if ($submit eq 'Abfragen') {
for ($i = 1; $i <= $pop->Count; $i++) {
foreach ($pop->Head($i)) {
/^(Subject): / and print $_, "<br>\n";
/^(From): / and print "<input type=\"submit\" value=\"$i\"
name=submit>" . $_, "\<br\>\n";
}
print "<br>\n";
}
}
elsif ($submit =~ /(\d)/) {
print $pop->Body($1), "\n";
print "juhu\n";
}
else {
print "Pooh\n";
}
------------------------------
Date: Fri, 31 Jul 1998 18:52:24 +0200
From: Michael Schmidt-Maier <MSchmidt@riedlingen.netsurf.de>
Subject: Mail::Pop3Client; Can not retrieve Body ;(
Message-Id: <35C1F648.49778A8C@riedlingen.netsurf.de>
Hi there all you Guru4s ;)
I finally come to the conclusion that I need your professional help with
this.
I am trying to retrieve Emails via the browser and use
thMail::Pop3Client modul. Everything works fine with retrievin headers
and subjects but I am not able to get the Body Text.
In the script below I get the "Juhu" Part but can4t see the body.
If I print the Body in the "If"-Part it displays fine, just the elsif
does not do what I want.
Any hints?
I send many thank yous in advance
Michael
#############Script fragment follows##################################
if ($submit eq 'Abfragen') {
for ($i = 1; $i <= $pop->Count; $i++) {
foreach ($pop->Head($i)) {
/^(Subject): / and print $_, "<br>\n";
/^(From): / and print "<input type=\"submit\" value=\"$i\"
name=submit>" . $_, "\<br\>\n";
}
print "<br>\n";
}
}
elsif ($submit =~ /(\d)/) {
print $pop->Body($1), "\n";
print "juhu\n";
}
else {
print "Pooh\n";
}
------------------------------
Date: Fri, 31 Jul 1998 18:52:46 +0200
From: Michael Schmidt-Maier <MSchmidt@riedlingen.netsurf.de>
Subject: Mail::Pop3Client; Can not retrieve Body ;(
Message-Id: <35C1F65E.DF417BFC@riedlingen.netsurf.de>
Hi there all you Guru4s ;)
I finally come to the conclusion that I need your professional help with
this.
I am trying to retrieve Emails via the browser and use
thMail::Pop3Client modul. Everything works fine with retrievin headers
and subjects but I am not able to get the Body Text.
In the script below I get the "Juhu" Part but can4t see the body.
If I print the Body in the "If"-Part it displays fine, just the elsif
does not do what I want.
Any hints?
I send many thank yous in advance
Michael
#############Script fragment follows##################################
if ($submit eq 'Abfragen') {
for ($i = 1; $i <= $pop->Count; $i++) {
foreach ($pop->Head($i)) {
/^(Subject): / and print $_, "<br>\n";
/^(From): / and print "<input type=\"submit\" value=\"$i\"
name=submit>" . $_, "\<br\>\n";
}
print "<br>\n";
}
}
elsif ($submit =~ /(\d)/) {
print $pop->Body($1), "\n";
print "juhu\n";
}
else {
print "Pooh\n";
}
------------------------------
Date: 29 Jul 1998 01:58:06 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: Memory Safe Hashes
Message-Id: <6pmh5u$2rp@fumnix.metronet.com>
horn@beaner.cs.wisc.edu (Jeffrey Horn) writes:
) I am writing a script that can potentially process ver large numbers of
) records through a hash. On a given machine, when the number of records
) in the hash is too large, Perl dies with an "out of memory" error.
)
) I've tried things like reducing key size and that helps some, but still
) I can get the problem to occur. I can tie the hash to a DBM file or Btree
) file, and that allows things to run, but much more slowly!
)
) What I am looking for is a structure which can keep a large window of
) data in a "in memory" data structure, but will keep data not in that
) window on disk... sort of a pageable DBM file.
It wouldn't be too hard to write a tied hash that would flush the
oldest entries to a DBM file whenever the N+1st entry is added
to the non-DBM hash. Someone may have already written it. The
overhead of tie and OO may mean it is no faster than direct DBM.
It certainly wouldn't be much of a win over direct DBM if most
key values only receive a single update before they get flushed
[in fact, it'd probably be even worse then direct DBM unless more
efficient use of disk buffers saved the day].
) Barring that, is there any way I can detect an out of memory state before
) it crashes my program?
Yes, if you build the Perl executable with the option to support
it enabled. Probably not the best solution. At least I recall
a "last chance" buffer you could tell Perl to use to run some
minimal code shortly after malloc() fails the first time. But
my quick search didn't turn it up so I might be misremembering.
I also recall an option for building Perl where you could ask it
how much memory it thinks it has available. -DDEBUGGING_MSTATS
does this but I'm not sure how or if these statistics are made
available to scripts.
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: 31 Jul 1998 19:52:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Memory Safe Hashes
Message-Id: <6pt7aj$l5r$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tye McQueen
<tye@fumnix.metronet.com>],
who wrote in article <6pmh5u$2rp@fumnix.metronet.com>:
> ) Barring that, is there any way I can detect an out of memory state before
> ) it crashes my program?
>
> Yes, if you build the Perl executable with the option to support
> it enabled. Probably not the best solution.
Depends on the application.
> At least I recall
> a "last chance" buffer you could tell Perl to use to run some
> minimal code shortly after malloc() fails the first time. But
> my quick search didn't turn it up so I might be misremembering.
$^M. Enabled by default in 5.005, but probably not-enough-tested.
Ilya
------------------------------
Date: Thu, 30 Jul 1998 12:46:30 -0400
From: "William L. Loucks" <loucksw@bright.net>
Subject: Newbie Perl Problem
Message-Id: <6pq8fc$s64$1@cletus.bright.net>
Even as 'root' on Linux Slackware 3.5, when
I try to run a Perl script, I get "Permission denied".
Any clues??? Thanks
W.Loucks <loucksw@bright.net>
------------------------------
Date: 30 Jul 1998 18:54:50 GMT
From: "Marjorie MacDonald" <mmacdonald@del.net>
Subject: Re: Newbie Perl Problem
Message-Id: <01bdbbeb$dad5df40$0e01a8c0@op.net>
OK, guys, help us newbies out! I have THREE PERL books, and while they
mention setting permissions in the script (and so have others here) NOWHERE
does it tell me exactly HOW I'm supposed to do this!
One book mentions a umask() command, and gives codes but no example of
proper syntax or where to put the @#$$#%#$% command.
I, too, keep getting this.. I have move stuff, renamed things, etc. All I
want to do is run a little database script I found. I'm not a total
programming dummy, but I haven't worked with this before and I don't run
the server... and the guys who do are absolutely no help at all.
At least I got them to tell me where the PERL interpreter is located... but
they're telling my that all my files have to end in cgi, and I see many
files referenced in my books that would have pl extensions. Do these go in
the cgi directory or someplace else?
Help!
Marjorie MacDonald
William L. Loucks <loucksw@bright.net> wrote in article
<6pq8fc$s64$1@cletus.bright.net>...
> Even as 'root' on Linux Slackware 3.5, when
> I try to run a Perl script, I get "Permission denied".
> Any clues??? Thanks
>
> W.Loucks <loucksw@bright.net>
>
>
>
------------------------------
Date: Thu, 30 Jul 1998 20:29:42 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: newbie split question
Message-Id: <35BEAC16.E92DB856@chesco.com>
tyler wrote:
>
> hello,
>
> im having trouble with split. im trying to read a file which is carat
> delimited, parsing each field into an array. my problem is that i'm using
> the split function to split it up and when i do, it doesnt work. however,
> when i change it from carat delimited to colon delimited, the code works.
> here's the code:
>
> open(MINN,"klaisjul2.txt") || die "no $!\n";
>
> while (<MINN>)
> {
> @list=split(/^/); # split up the fields
> chomp(@list); # take the carriage return off
> print $list[0],"\n"; # print out first field
> }
>
> close(MINN);
>
> what happens is when its like this, it prints out the entire line instead of
> the first field. if i change the ^ to a : and change the input file, it
> works fine. am i doing something stupid here? thanks in advance.
> oh, im using perl for win32
>
> tyler
You must ESCAPE the caret in the split...
@list=split(/\^/); # split up the fields
Good luck..
--
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3300
**************************************