[17953] in Perl-Users-Digest
Perl-Users Digest, Issue: 113 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 22 00:05:42 2001
Date: Sun, 21 Jan 2001 21:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <980139911-v10-i113@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 21 Jan 2001 Volume: 10 Number: 113
Today's topics:
Re: -e file check question (Eric Bohlman)
Re: -e file check question (Tad McClellan)
Re: -e file check question tzehua_tung@my-deja.com
Re: -e file check question tzehua_tung@my-deja.com
Re: -e file check question (Damian James)
Re: -e file check question (Tad McClellan)
[ANNOUNCE] XML::TokeParser 0.01 (Eric Bohlman)
Re: A hash of arrays (HELP) <mbenson@mediaone.net>
A strange gotcha with LWP, and it seems MLDBM <robert@chalmers.com.au>
Anyone with MLDBM experience out there? <robert@chalmers.com.au>
Assistance in Oz <scott.freeman@ccasoftware.com.au>
Re: Assistance in Oz <gracenews@optusnet.com.au>
Re: Assistance in Oz (Damian James)
Re: Deleting a line from file <gracenews@optusnet.com.au>
Re: GD.pm/ImageMagick - Any thing better? <smullett@omeninc.com>
Re: Helped on regular expression on emails <vinauser@lagvigator.com>
Re: Helped on regular expression on emails (Tad McClellan)
How do I read back saved-form data? (Perl Cookbook, pp6 <robert@chalmers.com.au>
Re: How to debug memory leak in a perl script? <Juha.Laiho@iki.fi>
http::daemon port stays open (NT) (zorgby)
immortal program : catching signals vivek@cse.iitd.ernet.in
Re: matrix <bwalton@rochester.rr.com>
Newbie: Anyone heard of Mail::Sender? <sound@sound-web.co.uk>
Re: Perl - Bytecode, Compile to C, Perl2EXE <gracenews@optusnet.com.au>
Re: Perl 500502 DBI does not work on V4R5 uzaemon@my-deja.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Jan 2001 00:22:33 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: -e file check question
Message-Id: <94fug9$fv1$1@bob.news.rcn.net>
tzehua_tung@my-deja.com wrote:
> I'm pretty new to this language, so please bare with my inexperience
> here. I'm working on a Windows 2000 machine using ActivePerl.
When you're pretty new to a language, you need to frequently consult that
language's reference material to make sure you're on the right track or,
as in this case, to find out that someone else has already done a big
chunk of the work for you.
> Here I'm trying to create a script that basically goes through all the
> subdirectories within a directory, and check for a file with a .dsc
> extension:
Every installation of Perl includes a standard module called File::Find
whose job it is to visit all the subdirectories within a directory. It's
well-optimized and tested. Learn how to use it. It will make your life a
lot simpler.
> #################################################
> opendir(TEST,"/test") || die "no test?: $!";
> while ($name = readdir(TEST)) {
> if (-d $name) {
Oops, you temporarily forgot (though you seem to have remembered it a few
lines down) that readdir() doesn't give you full path names. Your -d test
is looking in the current directory.
> if (($name ne ".") && ($name ne "..")) {
> print "$name\n";
> if (-e </test/$name/*AAA>) {
Here you remembered to prepend the path, but you've incorrectly assumed
that file-test operators take lists as arguments. The -e will be applied
only to the very first name returned by your glob, so it will succeed
only if by chance the file you're looking for happens to come up first in
the glob.
You could fix this by looping over the results of the glob and doing the
test there, but you'd really be better off learning how to use File::Find.
> print "\tAAA file found in $name\n";
> }
> else {
> print "\tcould not find AAA file in $name\n";
> }
> }
> }
> }
> closedir(TEST);
------------------------------
Date: Mon, 22 Jan 2001 00:51:13 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: -e file check question
Message-Id: <slrn96mpkh.hbj.tadmc@tadmc26.august.net>
tzehua_tung@my-deja.com <tzehua_tung@my-deja.com> wrote:
>
>Here I'm trying to create a script that basically goes through all the
>subdirectories within a directory, and check for a file with a .dsc
>extension:
>
>#################################################
>opendir(TEST,"/test") || die "no test?: $!";
^^^^^
>while ($name = readdir(TEST)) {
^^^^^
> if (-d $name) {
You are filetesting in the wrong directory there...
if (-d "/test/$name") {
[snip]
>Here is what I get as my output...
... so I don't believe you there.
Is that really your code? Did you type it in or use copy/paste?
Don't try typing code.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Jan 2001 03:12:00 GMT
From: tzehua_tung@my-deja.com
Subject: Re: -e file check question
Message-Id: <94g8ds$jn4$1@nnrp1.deja.com>
Thanks for the reply, just a few comments below...
> >#################################################
> >opendir(TEST,"/test") || die "no test?: $!";
> ^^^^^
> >while ($name = readdir(TEST)) {
> ^^^^^
> > if (-d $name) {
>
> You are filetesting in the wrong directory there...
...
> if (-d "/test/$name") {
>
This was also pointed out by Mr. Bohlman above, so I typed things in
and gave them a try... The funny thing is that it seems to give me the
same result (either $name or "\test\$name")...?
> [snip]
>
> >Here is what I get as my output...
>
> ... so I don't believe you there.
>
> Is that really your code? Did you type it in or use copy/paste?
> Don't try typing code.
I did copy & paste my code here, except that I changed the file name
extensions... Thanks for the suggestions though, I do make mistakes
when typing code and posting them on a web page.
Have a great day!
Peter Tung
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 03:15:28 GMT
From: tzehua_tung@my-deja.com
Subject: Re: -e file check question
Message-Id: <94g8kc$k0r$1@nnrp1.deja.com>
> Here you remembered to prepend the path, but you've incorrectly
assumed
> that file-test operators take lists as arguments. The -e will be
applied
> only to the very first name returned by your glob, so it will succeed
> only if by chance the file you're looking for happens to come up
first in
> the glob.
>
> You could fix this by looping over the results of the glob and doing
the
> test there, but you'd really be better off learning how to use
File::Find.
Thanks! I really should read a little more before posting here, but
time's not really my friend :)
About the -d check above... I tried typing in & not typing in the full
path name ("\test\$name" and just $name) and they gave me the same
result? Maybe it's just because I'm running the program in the "test"
directory. Time to read some more now, thanks!
Have a great day!
Peter
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 22 Jan 2001 03:30:40 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: -e file check question
Message-Id: <slrn96nac6.b9b.damian@puma.qimr.edu.au>
Thus spake tzehua_tung@my-deja.com on Mon, 22 Jan 2001 03:12:00 GMT:
[missing attribution, though Esc-1 Esc-p tells me the remarks came
from Tad McClellan]
>>
>> You are filetesting in the wrong directory there...
>...
>> if (-d "/test/$name") {
>>
>
>This was also pointed out by Mr. Bohlman above, so I typed things in
>and gave them a try... The funny thing is that it seems to give me the
>same result (either $name or "\test\$name")...?
>
You aren't really using backslashes there, are you? The above would be
looking for a directory in the current directory that starts with a tab
character and has a literal '$' in its name. If you try forward slashes,
you should find it does what you expect.
Cheers,
Damian
------------------------------
Date: Mon, 22 Jan 2001 03:44:27 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: -e file check question
Message-Id: <slrn96n3qb.hlp.tadmc@tadmc26.august.net>
Eric Bohlman <ebohlman@omsdev.com> wrote:
>tzehua_tung@my-deja.com wrote:
>> Here I'm trying to create a script that basically goes through all the
>> subdirectories within a directory, and check for a file with a .dsc
>> extension:
>
>Every installation of Perl includes a standard module called File::Find
Taken literally, there is no recursive searching going on, just
a single level of subdir, File::Find is N/A in that case.
>> opendir(TEST,"/test") || die "no test?: $!";
>> while ($name = readdir(TEST)) {
>> if (-d $name) {
>
>Oops, you temporarily forgot (though you seem to have remembered it a few
>lines down) that readdir() doesn't give you full path names. Your -d test
>is looking in the current directory.
That's where I stopped reading the code, because I became suspicious
that it wasn't the real code.
>> if (($name ne ".") && ($name ne "..")) {
>> print "$name\n";
>> if (-e </test/$name/*AAA>) {
>
>Here you remembered to prepend the path, but you've incorrectly assumed
>that file-test operators take lists as arguments. The -e will be applied
>only to the very first name returned by your glob, so it will succeed
>only if by chance the file you're looking for happens to come up first in
>the glob.
Errr, a -e test _must_ succeed on list elements returned from
a glob, that's what a glob does: return existing filesystem
objects :-)
I know this right off, because I just worked it out a few minutes
ago when _I_ started to write a followup pretty much like yours,
and then caught myself :-(
When I "mentally executed" the code, I couldn't explain his output
(even though I _do_ know scalar vs. list context).
So I copied the code, made the dir structure, and ran it.
Changed "/test"s to "test", I'm not making a dir in my filesystem
root just to try something out :-) Ran it again.
Fixed the -d path thing above. Ran it again.
Gots some warnings. This is where I _really_ stopped trying to
help (I was just being a hardass above, I have a reputation
to protect). One "red flag" item (code typo) can be overlooked.
Piling on a second one (no warnings enabled) means move on to
the next article.
But now you went and followed up, and I'm back so let's figure
out what's going on.
It has to do with the "statefulness" of globbing in scalar context.
mkdir test test/t1 test/t2 test/t3
touch test/t2/2.AAA test/t3/3.AAA
ran this:
-------------------------
#!/usr/bin/perl -w
use strict;
my $name;
opendir(TEST,"test") || die "no test?: $!";
while ($name = readdir(TEST)) {
if (-d "test/$name") {
if (($name ne ".") && ($name ne "..")) {
print "$name\n";
if ( -e <test/$name/*AAA>) {
print "\tAAA file found in $name\n";
}
else {
print "\tcould not find AAA file in $name\n";
}
}
}
}
closedir(TEST);
-------------------------
Got the output the OP described and 2 "uninitialized value" messages.
(note that you get the same output (no warnings) if you delete the
-e and just leave the glob in the if condition.
)
touch test/t2/foo.AAA
ran it again ... correct output! (by accident)
This "black box" testing seems to show that the third time the -e
is run, it gets the undef ending the list from the _second_ time.
So now we know what happened. I feel better.
An easy way to avoid the statefulness of glob() in scalar context
would be to use it in list context instead :-)
if ( my @a = <test/$name/*AAA>) { # instead of -e
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 2001 23:49:03 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: [ANNOUNCE] XML::TokeParser 0.01
Message-Id: <t6n1eaqkq7cs7f@corp.supernews.com>
XML::TokeParser provides a simplified interface to XML::Parser in much the
same way that Gisle Aas' HTML::Tokeparser provides a simplified interface
to HTML::Parser. It works in a "pull" (procedural) fashion (you call a
sub to get the next "token"--start tag, end tag, text string, comment, or
processing instruction--from the XML document) rather than a "push"
(event-driven) fashion (the parser calls your handler subs as it reads the
XML document). This allows your program to maintain state through
flow-of-control rather than shared flags.
XML::TokeParser has been uploaded to CPAN; if it hasn't made it to your
local mirror yet, it's also available at
<URL:http://www.omsdev.com/ebohlman/perlmodules/>.
------------------------------
Date: Mon, 22 Jan 2001 04:19:33 GMT
From: Michael Benson <mbenson@mediaone.net>
Subject: Re: A hash of arrays (HELP)
Message-Id: <3A6BB4BF.C8713DB7@mediaone.net>
The problem actually comes when i try to store the hash to a database and
then open it. I apologize for the confusion. The below code doesn't print
$hash{abc}[1]
Once again, any and all help will be
appreciated.
-Michael
#! /usr/local/bin/perl
dbmopen(%hash,"database",0666) || die("Error! $!");
$hash{abc}[0] = "this is line 1";
$hash{abc}[1] = "this is line 2";
$hash{bcd}[0] = "this is another line 1.";
dbmclose(%hash);
exit(0);
The above script seems to store the values to the database file but when i
try to retrieve the array values, nothing is printed.
e.g.
#! /usr/local/bin/perl
dbmopen(%hash,"database",0666) || die("couldn't open database. $!");
print $hash{abc}[0];
dbmclose(%hash);
exit(0);
Garry Williams wrote:
> On Sun, 21 Jan 2001 19:34:15 GMT, Michael Benson
> <mbenson@mediaone.net> wrote:
> > I am trying to create a hash of arrays but am having the hardest time
> >making it work. Can anyone see a problem in the below code?
> ^^^^^^^^^^^^^^
> What do you mean by that?
>
> >#! /usr/local/bin/perl
> >
> >$hash{abc}[0] = "this is line 1";
> >$hash{abc}[1] = "this is line 2";
> >$hash{bcd}[0] = "this is another line 1.";
> >
> >print $hash{abc}[1];
> >
> >exit(0);
>
> Other than strictures and warnings not enabled, no. What's the
> problem? What did you expect?
>
> --
> Garry Williams
------------------------------
Date: Mon, 22 Jan 2001 14:53:05 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: A strange gotcha with LWP, and it seems MLDBM
Message-Id: <h6Pa6.53$m51.15241@nsw.nnrp.telstra.net>
Running up some code here that does some domain stuff, and credit card
links, and discovered that if the enabled Crypt type was DES, then the
LWP:UserAgent call to the other site failed. Changed the Crypt type to
Blowfish, and it worked...
Now I find that MLDBM is showing similar behaviour.
In trying to save data so it's persistent across calls, the routine actaully
creates the data store, but simply wont fill it with the structure or data.
Everything else functions perfectly, just that. No errors - nothing. just an
empty structure. Works fine as a standalone, but not as part of the program!
dang nuisance.
Robert
------------------------------
Date: Mon, 22 Jan 2001 12:26:22 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: Anyone with MLDBM experience out there?
Message-Id: <LYMa6.42$m51.11529@nsw.nnrp.telstra.net>
Hi,
I have a small program - straight out of The Perl Cookbook basically - that
uses MLDBM for the persistent storage of data. (Page 506, 14.9)
Now, the program works fine as a standalone, but when I put it into a larger
program - it appears to work - no errors - creates the persistent store -
just doesn't store anything in it!
Now this is the same program almost that works fine as a standalone...
I think some other module must be interfering iwth it, but can't see what it
could be.
Any ideas anyone?
thanks
Bob
------------------------------
Date: Mon, 22 Jan 2001 15:06:19 +1100
From: "Scott Freeman" <scott.freeman@ccasoftware.com.au>
Subject: Assistance in Oz
Message-Id: <TkOa6.16$zO4.4057@vic.nntp.telstra.net>
Apologies if this is an inappropriate forum, but I am desperately seeking
perl programmers for numerous projects around Australia. I have sourced
Australia heavily, but have drawn a resounding blank with local talent.
Having observed this newsgroup over the last few days, there is a plethora
of intellectual property floating around. Does anyone know a top shelf
programmer wishing to live the high life in Australia (beaches, food and
wine, friendly people) or direct me to a forum where I might find one. Only
top class programmers should consider applying. Apologies again for my
intrusion.
Thanks and Regards
Scott Freeman
CCA Software
------------------------------
Date: Mon, 22 Jan 2001 14:20:06 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Assistance in Oz
Message-Id: <3a6bb508$0$15487$7f31c96c@news01.syd.optusnet.com.au>
"Scott Freeman" <scott.freeman@ccasoftware.com.au> wrote in message
news:TkOa6.16$zO4.4057@vic.nntp.telstra.net...
> Apologies if this is an inappropriate forum, but I am desperately seeking
> perl programmers for numerous projects around Australia. I have sourced
> Australia heavily, but have drawn a resounding blank with local talent.
It might have something to do with the other 433 Perl jobs being advertised.
(source: www.australianit.com.au)
You'll have to make your job stand out from the pack to attract high level
applicants.
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: 22 Jan 2001 04:25:53 GMT
From: damian@puma.qimr.edu.au (Damian James)
Subject: Re: Assistance in Oz
Message-Id: <slrn96ndjn.b9b.damian@puma.qimr.edu.au>
Thus spake Scott Freeman on Mon, 22 Jan 2001 15:06:19 +1100:
>Apologies if this is an inappropriate forum, but I am desperately seeking
This is a technical newsgroup. An appropriate forum would be a jobs
newsgroup.
>perl programmers for numerous projects around Australia. I have sourced
>Australia heavily, but have drawn a resounding blank with local talent.
I am not sure whether to find this insulting or complimentary -- does it
just mean that we all already have jobs? ;-)
>Having observed this newsgroup over the last few days, there is a plethora
>of intellectual property floating around. Does anyone know a top shelf
>programmer wishing to live the high life in Australia (beaches, food and
>wine, friendly people) or direct me to a forum where I might find one. Only
>top class programmers should consider applying. Apologies again for my
>intrusion.
Try aus.jobs
You could also try the SAGE-AU Jobs mailing list:
sage-au-jobs@sage-au.org.au
Cheers,
Damian
------------------------------
Date: Mon, 22 Jan 2001 13:02:53 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Deleting a line from file
Message-Id: <3a6ba2e7$0$15469$7f31c96c@news01.syd.optusnet.com.au>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn96ljop.gb2.tadmc@tadmc26.august.net...
> Jeffrey Grace <gracenews@optusnet.com.au> wrote:
> >"Tad McClellan" <tadmc@augustmail.com> wrote in message
> >news:slrn96j61l.9cm.tadmc@tadmc26.august.net...
<snip>
> >I wich to delete a line of text from a file, but there is a brief period
> >where the file will not exist, and an open (FH, > file) will re-create a
> >blank version.
>
>
> I think you are saying that you want a _real_ in-place edit, that is,
> you want the new file to have the same inode number as the original
> file. Would that solve your problem?
basically yes. Or any other method that can do the equivalent of keeping a
file locked during the removal of a line of text.
[snip]
> >Is there anything I can do to stop a new file from being created, I know
the
> >temp file will replace any created file at the rename, but any access to
the
> >file from another process before the rename will either see a blank file
or
> >no file. I've just thought about changing the appropriate opens to
sysopen
> >(with write but not create) but the file still won't exist at times. I
can
> >modify the code to retry on open for readings
> >eg:
> >open (FH, file) || open (FH, file), etc || die (message).
> >
> >Is there a better way?
In this I was wondering if there was a way to make the script block while it
waited for the file to exist.
I do not wish to manually check for existence (eg: using -e) since this is
non atomic.
>
>
> [ snip quoted .sig. Please do not quote signatures ]
whoops, was an accident, must of missed it during my hurried editing of the
reply.
>
I was hoping not to have to put the file into memory as it is a CGI script
and I'm worried about annoying the sysadmin, and getting my script deleted.
> If you can live with putting the entire file into memory,
> then you can edit the same inode by using open() with
> "+<" and:
>
> perldoc -f open
> perldoc -f seek
> perldoc -f truncate
>
>
<snip useful example>
Thankyou for the example, if I can't do it another way I'll have to do it
this way, and limit the length of the file, which unfortunately will turn
away some visitors since it was for the ticketing (read: sessions) system.
>
> --
> Tad McClellan SGML consulting
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Mon, 22 Jan 2001 00:47:09 GMT
From: Sterling <smullett@omeninc.com>
Subject: Re: GD.pm/ImageMagick - Any thing better?
Message-Id: <3A6B8328.A83A16D2@omeninc.com>
H-
Thanks for the reply and code.
A serious mistake I was making was not Read'ing the image after creating
it.
I was applying the background using background, and using geometry to
size the image.
After I did all that I was trying to print it out to standard output.
But since it wasn't actually creating the image it didn't print
anything. So there ya go.
Using your code I was able to successful create an image. (Although I
never got the colors to work correctly nor the fill.) But that wasn't
important at the time. I was just happy to see Image::Magick working.
Thanks for the details and explanation.
-Sterling
------------------------------
Date: Mon, 22 Jan 2001 11:12:46 +0800
From: "eechi von akusyumi" <vinauser@lagvigator.com>
Subject: Re: Helped on regular expression on emails
Message-Id: <94g8lp$3m53@imsp212.netvigator.com>
any pointers to modules?
--
Lamer is one who is lame,
£Q| Lamer \-/ RedHat User <==> RedHat's version = 7
<nobull@mail.com> wrote in message news:u966j9rs7a.fsf@wcl-l.bham.ac.uk...
> "Lamer" <evil@linuxhall.org> writes:
>
> > i need to convert:
> >
> > abc <def@ghi.com>
> > and
> > def@ghi.com (abc)
> >
> > into
> > <a href="mailto:def@ghi.com">abc</a>
>
> The full gammar of RFC822 mailbox headers is rather complex. Rather
> than producing a a RE that copes with a subset of RFC822 formats I
> recommend you use the appropriate module off of CPAN to cope with all
> possibilites.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Mon, 22 Jan 2001 04:39:48 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Helped on regular expression on emails
Message-Id: <slrn96n7d8.hsa.tadmc@tadmc26.august.net>
eechi von akusyumi <vinauser@lagvigator.com> wrote:
>any pointers to modules?
http://search.cpan.org/
Type "email" (without the quotes) in the little box thingie.
Click with your mouse on the "Search" button thingie.
see pointers to modules.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 22 Jan 2001 13:31:59 +1000
From: "Merlin" <robert@chalmers.com.au>
Subject: How do I read back saved-form data? (Perl Cookbook, pp698-700). a struggling perl learner....
Message-Id: <gWNa6.46$m51.13650@nsw.nnrp.telstra.net>
If this is called from a web page, as a CGI forexample, it saves all data
from the page...
...................................
referenceID=980119247
affiliate_id=
reg_username=robert
reg_password=12345
reg_domain=
reg_type=new
bulk_order=0
period=1
domain=chalmers.com
owner_first_name=Robert
owner_last_name=Chalmers
owner_org_name=dodgey brothers
owner_address1=P.O.003
owner_address2=
owner_address3=
..........................
open(FH, ">/tmp/form.dat") or die "Can't append to log: $!";
flock(FH, 2) or die "Can't lock log: $!";
my $query = CGI->new();
$query->save(*FH);
close(FH) or die "Can't close datalog: $!";
............................................................................
.
Now, if this is the code to read it back.... How on earth do I stuff the
data into %HTML in the same format. variable=value.
I know it's really simple, but I can't see it....
========================
my %HTML;
open(FH, "< /tmp/form.dat") or die "Cant open dat file: $!";
flock(FH, 1) or die "Can't lock dat file: $!";
while ($query = CGI->new(*FH)) {
last unless $query->param();
==========================
Thanks for any help here,
Robert
------------------------------
Date: 21 Jan 2001 14:18:51 +0200
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: How to debug memory leak in a perl script?
Message-Id: <94ek3b$di0$1@ichaos.ichaos-int>
stanb@panix.com (Stan Brown) said:
>On overnight test runs, with data streaming in at full speed from another
>perl script simulator, it appears to continue to grow in memory usage.
>
>Deletting the DB comiits, dose not fix this problem.
>
>Whats the best way to go baout debugng where it's leaking memory?
You hopefully already have warnings enabled, and have 'use strict;' in
effect.
Beyond that, all kinds of anonymous things you create would be my prime
suspects (are you really removing all references to those), closely
followed by some array or hash not being cleaned up. Then perhaps you
have a loop in which you create new database connections (or reopen files)
without closing the old ones.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a- C++ UH++++$ UL++++ P+@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5? !X R tv--- b+ DI? D G e+ h--- r+++ y+
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sun, 21 Jan 2001 23:48:32 GMT
From: iwantnospam@please.com (zorgby)
Subject: http::daemon port stays open (NT)
Message-Id: <t6mtgcfkk6ua0e@corp.supernews.com>
I've got a perl script that works as a proxy for NT, using http::Daemon.
It works great except that when I end the program, I have to use a different
port if I want to run it again. The darn port stays live and I can't figure
out how to close it. The only way I can use the same port is by waiting
several hours for it to die on its own, or to reset the machine.
The script below is the code I am using. It hangs on "my $connection =
$daemon->accept or redo;" I tried it without the redo at first. This script
differs a little from the sample loop in that I added an $eop detection
as a quick & dirty method of letting the loop actually end. It wasn't without
the $eop, although the port problem was still there.
Any ideas? Anyone? Hellllllppppp!
my $eop = 0; #check if end of program is requested
print "waiting for connection to open\n";
while ($eop == 0) {
print "waiting...\n";
my $connection = $daemon->accept or redo;
print "making page requests\n";
while ($eop && (my $request = $connection->get_request)) {
my $path = $request->url->path;
...
do some code based on the url request
...
my $response = new HTTP::Response;
$response->code(200);
$response->message("OK");
$response->header("Content-Type" => "text/html");
$response->header("Pragma" => "no-cache");
$response->content($content);
print "sending response to browser.";
$connection->send_response($response);
};
print "closing port, eop = $eop\n";
$connection->close;
undef($connection);
redo;
if ($eop) {exit(0);}
};
------------------------------
Date: Sun, 21 Jan 2001 04:55:58 GMT
From: vivek@cse.iitd.ernet.in
Subject: immortal program : catching signals
Message-Id: <94dq4s$p2c$1@nnrp1.deja.com>
hi all,
i wanna write a perl script which will run on X (linux) with root
owner....i want that a user should not be able to kill the script.....i
tried using %SIG for the same...but crossing out the window kills the
signal....i want to catch and ignore all the possible kill signals
(ofcourse barring a few like -9)....using %SIG for the same didn't
solved the purpose.....
Please suggest me a solution to trap all the signals and how to write an
immortal program.............
thanx and bye,
vivek malik
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Mon, 22 Jan 2001 02:49:35 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: matrix
Message-Id: <3A6BA089.354F63C6@rochester.rr.com>
smittod@auburn.edu wrote:
>
> I need a module that can build and display a matrix for me. Not a math
> matrix, but something more along the lines of a pyramid structure,
> showing levels down and nodes under nodes under nodes. It needs to show
> it's output in html. Does anybody know of a module like that?
...
You'll have to be much more descriptive and explicit about what you want
-- nobody can decipher from the above what you want. Maybe some
examples of what you mean by a "matrix" and its "display" would help.
--
Bob Walton
------------------------------
Date: Mon, 22 Jan 2001 00:36:43 +0000
From: sound <sound@sound-web.co.uk>
Subject: Newbie: Anyone heard of Mail::Sender?
Message-Id: <fsvm6t8vuneq8mvil4v2vsn3vpuqrko98b@4ax.com>
Hi,
I am a complete Newbie to perl and have had trouble getting a script
that will handle a form to email submission. Every script I have seen
seems to use Sendmail, but my ISP says it doesn't support that and
provides me with an example that uses Mail::sender instead. However,
there is no form parsing in this example and I was wondering how to go
about converting another script to use this Mail::sender thingie.
(Or even better, has anyone seen a script that uses such a
modification)
Any help would be appreciated, even if I am barking up the wrong tree.
Thanks
Dave
------------------------------
Date: Mon, 22 Jan 2001 12:29:18 +1000
From: "Jeffrey Grace" <gracenews@optusnet.com.au>
Subject: Re: Perl - Bytecode, Compile to C, Perl2EXE
Message-Id: <3a6b9b09$0$15470$7f31c96c@news01.syd.optusnet.com.au>
<jdf@pobox.com> wrote in message news:snmdow8f.fsf@pobox.com...
> > If you give away your Perl program, you can probably get free help.
>
> I think you get free help here even if you make good money off of your
> work. Or maybe now that I've admitted to being a fiend for cash, I'll
> be *plonked* with great ire and wrath!
>
> But I love to write programs, and I love to share ideas.
I too see no difference between someone that is paid to write Perl scripts,
and someone who write Perl scripts (sells them) and then get paid. Many of
the former get help here, why not the latter? And of course code theft is
more of an immediate finacial problem for someone of the latter persusion.
I wasn't aware that members of this newsgroup discriminated on the way
others used Perl.
>
> --
> Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
--
Jeffrey Grace
~~~~~~~~~~~~~~~~~~~~
Queensland, Australia
------------------------------
Date: Mon, 22 Jan 2001 02:18:24 GMT
From: uzaemon@my-deja.com
Subject: Re: Perl 500502 DBI does not work on V4R5
Message-Id: <94g59b$hau$1@nnrp1.deja.com>
Bruce,
Thank you very much for your reply.
> Are the CCSIDs of the two files identical?
Yes, both are 65535.
I tried another externally described physical file which has explicit
CCSID 37 and got same result (blanks on V4R5).
> Are you running Perl on Win32 or Unix (or maybe on the AS/400 itself)?
I'm running the Perl script on OS/400 (qshell), not on Win32/UNIX.
Any suggestions are appreciated.
uzaemon@Japan
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 113
**************************************