[24016] in Perl-Users-Digest
Perl-Users Digest, Issue: 6214 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 4 14:05:40 2004
Date: Thu, 4 Mar 2004 11:05:09 -0800 (PST)
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, 4 Mar 2004 Volume: 10 Number: 6214
Today's topics:
Re: 'require $test;' works? <ravisankars74@hotmail.com>
Re: Anyone got a good one-liner? (Peter Scott)
Re: Anyone got a good one-liner? <bmb@ginger.libs.uga.edu>
Re: Anyone got a good one-liner? <ittyspam@yahoo.com>
Re: Anyone got a good one-liner? <usenet@morrow.me.uk>
Re: Anyone got a good one-liner? <ittyspam@yahoo.com>
Re: how to see how many open file descriptors my progra <zentara@highstream.net>
Re: My PERL program slows down over time. <jurgenex@hotmail.com>
Re: Need help with Undeliverable Emails <jwillmore@remove.adelphia.net>
Re: new to perl <arthur0421@163.com>
Re: new to perl <sbryce@scottbryce.com>
Re: new to perl <s020274@cuhk.edu.hk>
Re: new to perl <s020274@cuhk.edu.hk>
Re: new to perl <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 4 Mar 2004 21:07:13 +0530
From: "Ravi" <ravisankars74@hotmail.com>
Subject: Re: 'require $test;' works?
Message-Id: <1078414536.504227@sj-nntpcache-5>
Just now I found the answer. Apparently only barewords works the way I
wanted to use the keyword 'require'.
In my case I have to use
eval "require $var";
Thanks,
Ravi
"Ravisankar Sivasubramaniam" <ravisankars74@hotmail.com> wrote in message
news:1078408327.942256@sj-nntpcache-5...
> I have package file as follows
>
> test.pm
> --------
> package test;
> ...
> ...
> 1;
> -------------------------
>
> I want to import the variables in this file to another. The compiler goes
> through if I add
>
> require test;
>
> but fails with the following error message if I add
>
> $var = test;
> require $var;
>
> Can't locate test in @INC (@INC contains:
> /opt/perl/packages/5.004_04/sparc-sun-solaris2.6/lib
> /opt/perl/packages/5.004_04/lib
> /opt/perl/packages/5.004_04/lib/site_perl/sparc-sun-solaris2.6
> /opt/perl/packages/5.004_04/lib/site_perl .) at UpgradeNodes.pl line 26.
>
> Can anyone tell what the problem?
>
> Thanks,
> Ravi
>
>
------------------------------
Date: Thu, 04 Mar 2004 15:14:21 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Anyone got a good one-liner?
Message-Id: <hJH1c.686271$X%5.123298@pd7tw2no>
In article <4046ff9c$0$17706$3b214f66@usenet.univie.ac.at>,
Heinrich.Mislik@univie.ac.at (Heinrich Mislik) writes:
>In article <LSm1c.676406$X%5.168900@pd7tw2no>, peter@PSDT.com says...
>>Using said more robust way (untested):
>>
>>my @col_names = keys %sqlUpdatePairs;
>>my $sql = "UPDATE foo SET "
>> . join("," => map "$_ = ?" => @col_names)
>> . " WHERE blah";
>>my $sth = $dbh->prepare($sql);
>>#...
>>$sth->execute(@sqlUpdatePairs{@col_names});
>
>This can be shorter (still untested):
>
>my $sql = "UPDATE foo SET "
> . join("," => map "$_ = ?" => keys %sqlUpdatePairs)
> . " WHERE blah";
>my $sth = $dbh->prepare($sql);
>#...
>$sth->execute(values %sqlUpdatePairs);
>
>perldoc -f keys explicitly states that keys and values will use the same order.
...provided that the hash has not been modified in between. I was making no
assumptions about values being set during the "..." part of the code.
--
Peter Scott
http://www.perldebugged.com/
*** NEW *** http://www.perlmedic.com/
------------------------------
Date: Thu, 4 Mar 2004 10:22:02 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Anyone got a good one-liner?
Message-Id: <Pine.A41.4.58.0403041011050.15910@ginger.libs.uga.edu>
On Wed, 3 Mar 2004, John W. Krahn wrote:
> "D. Alvarado" wrote:
> > I have a hash
> > %sqlUpdatePairs
> > whose key and value are both scalar strings. What I would like is a
> > resulting string, resembling
> > "COL1 = 'val1', COL2 = 'val2', COL3 = 'val3'"
> ( $string = join( "\0", %sqlUpdatePairs ) . "'" ) =~ s/\0/ $|-- ? "', " : " = '" /eg;
Fascinating! I was wondering how to do that.
perl -le 'print $|-- for 1..5'
0
1
0
1
0
perl -le 'print $|=$_ for -2..2'
1
1
0
1
1
perl -le 'print $|++ for 1..5'
0
1
1
1
1
Apparently, setting $| to any non-zero value sets it to 1. I don't see
that behavior described in perlvar...
Regards,
Brad
------------------------------
Date: Thu, 4 Mar 2004 10:59:56 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Anyone got a good one-liner?
Message-Id: <20040304105828.E27834@dishwasher.cs.rpi.edu>
On Thu, 4 Mar 2004, Brad Baxter wrote:
> Apparently, setting $| to any non-zero value sets it to 1. I don't see
> that behavior described in perlvar...
Really? I see it...
"If set to nonzero, forces a flush right away and after every write or
print on the currently selected output channel. Default is 0 ..."
There's no difference between 1 and any other non-zero value. Why are you
thinking 1 is special?
Paul Lalli
------------------------------
Date: Thu, 4 Mar 2004 16:07:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Anyone got a good one-liner?
Message-Id: <c27k75$jri$1@wisteria.csv.warwick.ac.uk>
Paul Lalli <ittyspam@yahoo.com> wrote:
> On Thu, 4 Mar 2004, Brad Baxter wrote:
>
> > Apparently, setting $| to any non-zero value sets it to 1. I don't see
> > that behavior described in perlvar...
>
> Really? I see it...
>
> "If set to nonzero, forces a flush right away and after every write or
> print on the currently selected output channel. Default is 0 ..."
>
> There's no difference between 1 and any other non-zero value. Why are you
> thinking 1 is special?
No, his point is that this
perl -le'$| = 2; print $|'
prints 1, not 2. It kinda makes sense, but it isn't documented.
Ben
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Thu, 4 Mar 2004 11:40:24 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Anyone got a good one-liner?
Message-Id: <20040304113943.U27834@dishwasher.cs.rpi.edu>
On Thu, 4 Mar 2004, Ben Morrow wrote:
> Paul Lalli <ittyspam@yahoo.com> wrote:
> > On Thu, 4 Mar 2004, Brad Baxter wrote:
> >
> > > Apparently, setting $| to any non-zero value sets it to 1. I don't see
> > > that behavior described in perlvar...
> >
> > Really? I see it...
> >
> > "If set to nonzero, forces a flush right away and after every write or
> > print on the currently selected output channel. Default is 0 ..."
> >
> > There's no difference between 1 and any other non-zero value. Why are you
> > thinking 1 is special?
>
> No, his point is that this
>
> perl -le'$| = 2; print $|'
>
> prints 1, not 2. It kinda makes sense, but it isn't documented.
Ohhh. My mistake. Apologies to Brad for that one.
Paul Lalli
------------------------------
Date: Thu, 04 Mar 2004 11:53:22 -0500
From: zentara <zentara@highstream.net>
Subject: Re: how to see how many open file descriptors my program has?
Message-Id: <ocne40l16av6iop4ej431rp6li37054lvl@4ax.com>
On 4 Mar 2004 01:54:34 -0800, uffesterner@spamhole.com (Rex Gustavus
Adolphus) wrote:
>This question is about a pre-5.6-perl
>
>I wonder if there is a command
>to see how many open file descriptors my program has?
#!/usr/bin/perl
use FileHandle;
my @handles = map FileHandle->new_from_fd($_, "r"), 0..100;
print "@handles\n";
# Handles that aren't open come back as undef in this array.
# So $handles[0] is STDIN, etc.
# If you don't need the mapping from specific fd, then add
# grep defined($_), in front of the map.
>And is there a command
>to see how many open file descriptors the system has?
You could do a count of all the entries in /proc.
Each numbered directory has a fd subdir, which has the file
descriptors. Just count them?
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: Thu, 04 Mar 2004 15:03:48 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: My PERL program slows down over time.
Message-Id: <ozH1c.39086$6K.21257@nwrddc02.gnilink.net>
Marc wrote:
> I wrote a PERL program to creat thousands of files. The program zips
> along at first but then begins to slow down.
>
> Does any one have any ideas on what might be causing this?
Your while loop on line 42 causes a memory leak.
jue
------------------------------
Date: Thu, 04 Mar 2004 10:51:59 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Need help with Undeliverable Emails
Message-Id: <pan.2004.03.04.15.51.57.644634@remove.adelphia.net>
On Thu, 04 Mar 2004 13:18:08 +1100, great places to stay. wrote:
> Hi,
>
> I do hope there is a person out there that can help.
>
> My problem is when my perl script sends out an email using perls /sendmail
> to one of my users, that have added their email address to one of my forms
> the email is bounced back if it is undeliverable.
>
> The problem I have is my ISP can't work out how to get those bounced emails
> to be sent back to my email address so I am aware that an email sent by
> /sendmail in perl has not been delivered.
>
> Any help would be greatly appreciated.
Code ... that would be appriciated :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
A door is what a dog is perpetually on the wrong side of. --
Ogden Nash
------------------------------
Date: Thu, 04 Mar 2004 22:41:16 +0800
From: Regent <arthur0421@163.com>
Subject: Re: new to perl
Message-Id: <c27f7i$agl$1@mail.cn99.com>
Ben Morrow wrote:
> Regent <arthur0421@163.com> wrote:
>
>>Tony Muler wrote:
>>
>>>Regent wrote:
>>>
>>>
>>>>Well, I believe your shebang line should be
>>>>
>>>>#!c:\perl\bin\perl
>>>
>>>And I believe the shebang is not necessary at all
>>>on Windows. Right?
>>
>>Why not?
>
>
> Err... because Windows doesn't follow the #! convention? It does have a use,
> however: perl will read switches from the #! line if it is there. This can
> be the only way to specify -T.
>
> Ben
>
Eh, I'm programming Perl cgi with Apache, so the shebang is necessary.
Regent
------------------------------
Date: Thu, 04 Mar 2004 10:19:44 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: new to perl
Message-Id: <104ep9bao89v817@corp.supernews.com>
Regent wrote:
> Oh really. Does this mean the shebang can be omitted, if no switch is
> used?
I believe the correct answer is, It depends.
If your system is configured to look up the .pl extension in the system
registry and determine from that to use the perl interpreter to run the
script, then the shebang can be left out. Otherwise, you need to leave
it in.
------------------------------
Date: Fri, 5 Mar 2004 01:36:34 +0800
From: "Tsui Wai-ming" <s020274@cuhk.edu.hk>
Subject: Re: new to perl
Message-Id: <c27p1s$1etj$1@justice.itsc.cuhk.edu.hk>
Thanks everybody! I changed a line in httpd.conf and now i'm able to learn
CGI!
The line is the one starts with "scripalias".
And i've learnt a lot from all the replies too!
Ming~
"Tsui Wai-ming" <s020274@cuhk.edu.hk> ¼¶¼g©ó¶l¥ó·s»D
:c24ved$4qq$1@justice.itsc.cuhk.edu.hk...
> I just started to learn CGI by writing a perl script, but what appeared on
> the browser was exactly what I'd typed in the editor, minus the
> <title>xxx</title> line.
>
> This is the script I wrote, in fact it is what I directly copied from
"Perl
> How to Program":
>
> #!c:\perl\bin
> #displaying time in brower
>
> print "Content-type: text/html\n\n";
> print "<html><head><title>Hello!</title>";
> print "</head>\n<body>";
> print scalar( localtime() );
> print "</body></html>"
>
> Many thanks!!!
>
>
>
------------------------------
Date: Fri, 5 Mar 2004 01:38:40 +0800
From: "Tsui Wai-ming" <s020274@cuhk.edu.hk>
Subject: Re: new to perl
Message-Id: <c27p5q$1f0a$1@justice.itsc.cuhk.edu.hk>
In fact I just changed to
#!C:\perl\bin\perl
This one
# perl, and
#!C:\perl\bin
didnt work at all...
"Scott Bryce" <sbryce@scottbryce.com> ¼¶¼g©ó¶l¥ó·s»D
:104ep9bao89v817@corp.supernews.com...
> Regent wrote:
>
> > Oh really. Does this mean the shebang can be omitted, if no switch is
> > used?
>
> I believe the correct answer is, It depends.
>
> If your system is configured to look up the .pl extension in the system
> registry and determine from that to use the perl interpreter to run the
> script, then the shebang can be left out. Otherwise, you need to leave
> it in.
>
------------------------------
Date: Thu, 4 Mar 2004 17:33:45 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: new to perl
Message-Id: <c27p9p$njh$1@wisteria.csv.warwick.ac.uk>
Scott Bryce <sbryce@scottbryce.com> wrote:
> Regent wrote:
>
> > Oh really. Does this mean the shebang can be omitted, if no switch is
> > used?
>
> I believe the correct answer is, It depends.
>
> If your system is configured to look up the .pl extension in the system
> registry and determine from that to use the perl interpreter to run the
> script, then the shebang can be left out. Otherwise, you need to leave
> it in.
No, it will make no difference. Windows *never* looks for a #! line, so
it doesn't matter if it's there or not. Apache may be a different
matter, of course.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6214
***************************************