[23477] in Perl-Users-Digest
Perl-Users Digest, Issue: 5691 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 21 14:07:51 2003
Date: Tue, 21 Oct 2003 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 21 Oct 2003 Volume: 10 Number: 5691
Today's topics:
Re: Arguments to CORE::pipe? <newspost@coppit.org>
Re: C vs Perl <dha@panix.com>
Re: C vs Perl <Chris@Sonnack.com>
Re: C vs Perl <hyagillot@tesco.net>
Re: chmod 666 not working from perl script <jwillmore@remove.adelphia.net>
Re: commands, which is better <ernst-udo.wallenborn@freenet.de>
Re: commands, which is better (Tad McClellan)
Re: commands, which is better <spam@thecouch.homeip.net>
Re: Help me with is code <syscjm@gwu.edu>
Re: Help me with is code <tom@nosleep.net>
Re: Help me with is code <peter@semantico.com>
Re: Help me with is code (Tad McClellan)
Re: Help me with is code (Tad McClellan)
Re: Help me with is code <dha@panix.com>
Re: Help me with is code <flavell@ph.gla.ac.uk>
Re: How to propagate -w and use strict? <lusol@Dragonfly.cc.lehigh.edu>
Re: IO::Socket::INET - Listen on exactly two IPs the sa <uri@stemsystems.com>
Re: performance arrays vs hashes <tore@aursand.no>
Re: performance arrays vs hashes <jurgenex@hotmail.com>
Re: Perl and IIS - script runs but 'The page cannot be <asu1@c-o-r-n-e-l-l.edu>
Re: Perl and IIS - script runs but 'The page cannot be <jwillmore@remove.adelphia.net>
Re: Perl and IIS - script runs but 'The page cannot be (Roy Johnson)
Re: Quick Perl question (Roy Johnson)
Re: Quick Perl question <syscjm@gwu.edu>
Re: Quick Perl question <grazz@pobox.com>
Re: Rookie: Constructing a large SQL INSERT statement <jwillmore@remove.adelphia.net>
Re: rsh & perl -Directory creation not possible (qazmlp)
Re: rsh & perl -Directory creation not possible (Roy Johnson)
Re: Setting config file using constant (Roy Johnson)
Re: Use in if..elsif (Roy Johnson)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Oct 2003 17:53:28 GMT
From: David Coppit <newspost@coppit.org>
Subject: Re: Arguments to CORE::pipe?
Message-Id: <Pine.BSF.4.56.0310211348380.95470@www.provisio.net>
On Tue, 21 Oct 2003, Steve Grazzini wrote:
> >> Is the correct solution to export a custom pipe() that overrides
> >> CORE::pipe, and hope that no one tries to do the same thing?
>
> I would have tried (not sure if it's practical) to use *$r as the real
> glob/filehandle instead of tied(*$r)->{fh}.
That approach eventually dawned on me after I reread your explanation this
morning. It appears to be working so far... Watch CPAN for FileHandle::Unget
soon. :)
sub new
{
my $class = shift;
my $self = $class->SUPER::new(@_);
return undef unless defined $self;
# The ::Tie class stores the handle as $self->{'fh'}
tie *$self, "${class}::Tie", $self;
# More info on this approach is in IO::Handle, NOTE section
${*$self}{'filehandle_unget_buffer'} = '';
bless $self, $class;
return $self;
}
Thanks,
David
------------------------------
Date: Tue, 21 Oct 2003 16:23:26 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: C vs Perl
Message-Id: <slrnbpanbu.ob1.dha@panix2.panix.com>
In article <3F94CFE6.ACE8FE5C@terra.es>, Julián Albo wrote:
> len v escribió:
>
>> > Yes, and I could implement a language called FoxTrot that would have the
>> > following program:
>> >
>> > Do it
>
> (...)
>
>> I see your point and that is exactly what Perl is all about. If your
>> FoxTrot implementation had something to offer the community then FoxTrot
>> would be added to Perl.
>
> Something like...?
> use Bizarre::FoxTrot;
I'd use Acme:: rather than create a new namespace... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I didn't jump. I took a tiny step and the conclusions were right
there. - Buffy
------------------------------
Date: Tue, 21 Oct 2003 12:06:34 -0500
From: Programmer Dude <Chris@Sonnack.com>
Subject: Re: C vs Perl
Message-Id: <3F95679A.8E6C8487@Sonnack.com>
len v wrote:
>>>> ...causing me to edit the origional comic.
>>>
>>> "Origional" ??
>
> Looks like I spelled it wrong on the web site too.
That was why I mentioned it. (-:
> I've always maintained that a programmer does not have to spell
> correctly, just consistent, either right or wrong - the syntax
> checker does not care.
I would disagree. For many reasons.
Comments, tech docs, communicating effectively with others.....
--
|_ CJSonnack <Chris@Sonnack.com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|_______________________|
------------------------------
Date: Tue, 21 Oct 2003 17:38:24 +0000 (UTC)
From: "W K" <hyagillot@tesco.net>
Subject: Re: C vs Perl
Message-Id: <bn3qug$sfo$1@hercules.btinternet.com>
"Programmer Dude" <Chris@Sonnack.com> wrote in message
news:3F95679A.8E6C8487@Sonnack.com...
> len v wrote:
>
> >>>> ...causing me to edit the origional comic.
> >>>
> >>> "Origional" ??
> >
> > Looks like I spelled it wrong on the web site too.
>
> That was why I mentioned it. (-:
>
> > I've always maintained that a programmer does not have to spell
> > correctly, just consistent, either right or wrong - the syntax
> > checker does not care.
>
> I would disagree. For many reasons.
>
> Comments, tech docs, communicating effectively with others.....
They're all dyslexic too, so it doesn't matter.
------------------------------
Date: Tue, 21 Oct 2003 15:42:52 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: chmod 666 not working from perl script
Message-Id: <20031021114319.243623db.jwillmore@remove.adelphia.net>
On Tue, 21 Oct 2003 12:16:02 GMT
"Travis" <dingdongy2k@hotmail.com> wrote:
>
>
> chmod(0666, $actfileback);
Should be:
chmod(0666, $actfileback) or die "Could not chmod: $!\n";
If you get an "Operation not permitted" message, you're not picking it
up. Especially if you're running the script _without_ warnings
enabled. Consider these two command line examples:
jim@maxine:~> perl -e 'chmod(0777, "/root");'
jim@maxine:~> perl -e 'chmod(0777, "/root") or die "$!\n";'
Operation not permitted
jim@maxine:~>
The first does _not_ check for errors/warnings, but does _not_ fail
either. The second tells you that the command had an issue.
> use File::Copy;
> $status = copy( $actfile, $actfileback );
Again, you need to check for warnings/erros.
>
> This works fine if I first create the file in $actfileback
> BUT I have to set chmod 666 from my ftp program.
>
> When I create the file but try to set the chmod 666 as I have shown
> above it apparently does not set the 666 since the copy does not
> work.
>
> Any ideas what I did wrong?
>
> Also, is there any way to do the copy without first creating the
> file?
Run the script with warnings enabled ('-w' switch on the first line).
_Always_ check to see what the command/fuction returns.
HTH
--
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 ...
We have only two things to worry about: That things will never
<get back to normal, and that they already have.
------------------------------
Date: 21 Oct 2003 17:44:55 +0200
From: Ernst-Udo Wallenborn <ernst-udo.wallenborn@freenet.de>
Subject: Re: commands, which is better
Message-Id: <m3vfqih9xk.udo@no.domain.net>
Robert Wallace <robertw@nospam.acm.org> writes:
[snip]
> is there a difference? is there a situation where I would use one over
> the other?
[snip]
> # this one ##########################################################
> open (SYS, "/temp/uptime.exe |");
[snip]
> # and this one
> $sys=`/temp/uptime.exe`;
On *NIX, both commands do almost the same. Both fork a child and both execute
the command in a subshell. The first method reads the output of uptime.exe
line-by-line, which allows you to close the handle as soon as you read the
data you're interested in. If tha output of uptime.exe was very long, this
difference would matter.
You probably want to read the perlipc manpage.
--
Ernst-Udo Wallenborn
------------------------------
Date: Tue, 21 Oct 2003 11:27:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: commands, which is better
Message-Id: <slrnbpanik.1ln.tadmc@magna.augustmail.com>
[ top-posting corrected. ]
Anand <some@one.com> wrote:
> Robert Wallace wrote:
>> I tried the following two methods. both works. both produce the same
>> output.
>> is there a difference?
>> open (SYS, "/temp/uptime.exe |");
>> $sys=`/temp/uptime.exe`;
> second one will fork new process as you are using *NIX thing.
So will the first one.
Neither of them does the "*NIX thing".
Nearly every OS needs a process to run a program in.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Oct 2003 13:41:47 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: commands, which is better
Message-Id: <xdelb.50130$4y4.1527190@weber.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
[Please do NOT top-post]
> Robert Wallace wrote:
>
>> i'm trying to run a system command like ls,dir,ping,uptime, etc...
>>
>> I tried the following two methods. both works. both produce the same
>> output.
>> is there a difference? is there a situation where I would use one over
>> the other? I guess the open allows me to do more on-the-fly stuff.
>> what else?
>>
>>
>>
>> # this one ##########################################################
>> open (SYS, "/temp/uptime.exe |");
>> while($the_sys = <SYS>){
>> $the_sys =~ s/\015\012/<br>\015\012/g;
>> print $the_sys . "<br>\n";
>> }
>> close (SYS);
>>
>>
>> # and this one
>> ##########################################################
>> $sys=`/temp/uptime.exe`;
>> $sys=~s/\015\012/<br>\015\012/g;
>> print $sys;
>
>
Anand wrote:
> second one will fork new process as you are using *NIX thing. If you do
> not want to create new process (which will take some or more system
> resources) you are better off using PURE perl as in case of first example.
>
> --Anand
>
That's not correct. The first example also forks a second process.
The only difference is in the first example you're reading the output yourself line-by-line, while
with the second example perl does that job for you and returns the whole output in one chunk.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE/lW/eeS99pGMif6wRAph4AJ9vkInKaXZZ/y9385wblxpAqYgj1wCeIDVI
Sxfis+WkDK9psa5bc1yuYmU=
=wcX4
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 21 Oct 2003 11:26:36 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Help me with is code
Message-Id: <3F95502C.7070108@gwu.edu>
Public Interest wrote:
>>>I can put whatever address here.
>>
>>
>>So long then.
>>
>>
>>--
>> Tad McClellan SGML consulting
>> tadmc@augustmail.com Perl programming
>> Fort Worth, Texas
>
>
> Do you expect anyone to post a real email here to receive spams?
Tad does. I do.
> I opened a
> temp address last time and within 3 days I put a message on newsgroup, I
> start getting 10 the "MS patch" virus per hour. I am not sure if somebody
> scaned my address or his/her computer is infected with this virus.
>
That's what SpamAssassin was made for.
Chris Mattern
------------------------------
Date: Tue, 21 Oct 2003 09:10:09 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: Help me with is code
Message-Id: <3f95599d$1@nntp0.pdx.net>
> That's what SpamAssassin was made for.
>
> Chris Mattern
>
Yeah, let's do some dumbass shit so another startup can make it and take
another $50/year from us (on top of the other 5@ $50) to keep our machines
running.
------------------------------
Date: Tue, 21 Oct 2003 17:23:43 +0100
From: Peter Hickman <peter@semantico.com>
Subject: Re: Help me with is code
Message-Id: <3f955d8f$0$28262$afc38c87@news.easynet.co.uk>
Lets review the facts here.
1) You have designed two systems
2) They are 100% effective
3) The anti-spam systems are too easy to design
4) The anti-spam systems are too easy to implement
5) You are not using them
You quite clearly have no faith in your own self proclaimed genius, and
neither do we.
BTW. Who ties your shoe laces for you?
------------------------------
Date: Tue, 21 Oct 2003 11:22:04 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help me with is code
Message-Id: <slrnbpan9c.1ln.tadmc@magna.augustmail.com>
Chris Mattern <syscjm@gwu.edu> wrote:
> Public Interest wrote:
>>>>I can put whatever address here.
^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^
>> Do you expect anyone to post a real email here to receive spams?
>
> Tad does.
No I don't.
I expect that a munged address will *look* munged so people do not
waste time trying to reply via email.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Oct 2003 11:23:52 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help me with is code
Message-Id: <slrnbpanco.1ln.tadmc@magna.augustmail.com>
Tom <tom@nosleep.net> wrote:
>> That's what SpamAssassin was made for.
>>
>> Chris Mattern
>>
>
> Yeah, let's do some dumbass shit so another startup can make it and take
> another $50/year from us
SpamAssassin costs $0/year.
> (on top of the other 5@ $50) to keep our machines
> running.
If you buy Bill's brainwashing, then you pay the consequences.
My machines stay running without sending money to anyone.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Oct 2003 16:45:35 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Help me with is code
Message-Id: <slrnbpaolf.ob1.dha@panix2.panix.com>
In article <3f95599d$1@nntp0.pdx.net>, Tom wrote:
>> That's what SpamAssassin was made for.
>>
>> Chris Mattern
>>
>
> Yeah, let's do some dumbass shit so another startup can make it and take
> another $50/year from us (on top of the other 5@ $50) to keep our machines
> running.
I know I probably shouldn't get involved here, but...
What in the world is that supposed to mean? Who exactly is supposed to
be extracting money from whom here?
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"I go where I will and I do what I can" - Henry Fool
------------------------------
Date: Tue, 21 Oct 2003 18:08:11 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Help me with is code
Message-Id: <Pine.LNX.4.53.0310211801440.9628@ppepc56.ph.gla.ac.uk>
On Tue, 21 Oct 2003, Tad McClellan wrote:
> My machines stay running without sending money to anyone.
As opposed to the folks whose machines keep stopping and/or having to
be rebooted in spite of them sending money, I guess. SCNR.
------------------------------
Date: 21 Oct 2003 15:53:42 GMT
From: Steve Lidie <lusol@Dragonfly.cc.lehigh.edu>
Subject: Re: How to propagate -w and use strict?
Message-Id: <bn3kq6$agk@fidoii.CC.Lehigh.EDU>
Tad McClellan <tadmc@augustmail.com> wrote:
> Steve Lidie <lusol@Dragonfly.cc.lehigh.edu> wrote:
>
>> but was misled by testing only using a "used once" error.
> ^^^^^
>
> You mean a "used once" _warning_.
Yes, a used once diagnostic.
------------------------------
Date: Tue, 21 Oct 2003 15:44:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: IO::Socket::INET - Listen on exactly two IPs the same time?
Message-Id: <x7y8velhmy.fsf@mail.sysarch.com>
>>>>> "KB" == Kai Bleek <public@spellweaver.de> writes:
>> the socket system only allows binding to one IP/port pair or wildcarding
>> any IP with a single port.
KB> Hm, well, that's a pity.
note that this is not a perl restriction but one that came with the
original BSD socket API. the whole socket/bind/listen api is geared
towards one address and would have been very ugly if it supported
multiple addresses. using select on those multiple sockets is not
difficult and works around the problem nicely. you would want select to
be used in any case for any proper server so this adds very little code
to listen to more than one address on the same port.
KB> # Adding to select:
KB> my $read_set = new IO::Select();
KB> $read_set->add($server_remote);
KB> $read_set->add($server_local);
KB> # entering loop
KB> while (1) {
KB> my @select_set = $read_set->can_read;
KB> foreach my $server (@select_set) {
KB> # distinguish between socket-IPs
KB> if ($server == $server_remote) {
KB> my $connect = $server->accept();
KB> $read_set->add($connect);
KB> # some Code...
KB> $read_set->remove($connect);
KB> $connect->close;
KB> } elsif ($server == $server_local) {
KB> my $connect = $server->accept();
KB> $read_set->add($connect);
KB> # some different code
KB> $read_set->remove($connect);
why do you remove the $connect when you don't add it to the io::select
set? unless you do that elsewhere. and then you would need to check for
a connected socket vs a listen socket.
KB> $connect->close;
KB> }
KB> }
KB> }
there are better ways to do that. i would use the $server_local and
$server_local objects as keys to a dispatch table hash and then dispatch
based on what socket was returned from io::select. then the body of your
loop is much cleaner and easier to extend just by adding entries into
the dispatch table.
<untested>
$read_set->add($server_remote);
$listen_handler{$server_remote} = \&remote_handler ;
$read_set->add($server_local);
$listen_handler{$server_local} = \&local_handler ;
# entering loop
while (1) {
my @select_set = $read_set->can_read;
foreach my $server (@select_set) {
my $connect = $server->accept();
my $handler = $listen_handler{$server} ;
# here you could check if it is a listen socket or a connected one by
#seeing if you got a handler for it.
$handler->( $connect ) ;
$connect->close;
}
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Tue, 21 Oct 2003 19:50:48 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: performance arrays vs hashes
Message-Id: <pan.2003.10.21.14.19.05.383684@aursand.no>
On Tue, 21 Oct 2003 07:08:38 -0700, Thomas wrote:
> using hashes is better than using arrays...(or isnt so ?)
Can't compare to totally different data types. You should use hashes when
using hashes are appropriate, and vice versa.
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Tue, 21 Oct 2003 17:52:38 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: performance arrays vs hashes
Message-Id: <Gnelb.48480$mp1.34389@nwrddc02.gnilink.net>
Thomas wrote:
> i dont know enough of perl to describe,
> using hashes is better than using arrays...(or isnt so ?)
I don't know enough about DoItYourself to describe,
using a hammer is better than using a screw driver ... (or isnt so?)
Well, it all depends on what you want to do with it...
jue
------------------------------
Date: 21 Oct 2003 15:05:17 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <Xns941B70CB78211asu1cornelledu@132.236.56.8>
stewart@webslave.dircon.co.uk (stew dean) wrote in
news:2b68957a.0310210253.38464359@posting.google.com:
> This is not a pure Perl problem but is to do with the running of Perl
> on IIS.
>
> I now have two scripts that run without errors (I'm using strict) but,
> for some reason, will not display the simple 'Done!' page built into
> the script. Instead the server gives me 'The page cannot be
> displayed'.
And we are supposed to divine what is going on without seeing a line of
code?
> I have run it on a local IIS set up with no problems but on the main
> server I continue to get this error. As I have no error messages other
> than page not displayed I'm not sure what I can tweak to get it to
> work. Maybe there's an error log I could look at?
There probably is. Why don't you look at it?
> I need to get a HTML page displayed at the end so I can then do futher
> steps but so far cannot.
...
> Any help appreciated.
To get any help, you'll need top provide some information. Also, make
sure this is not a web server configuration or CGI issue. Please refer to
the posting guidelines for this group at
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
Without at least seeing a short example script that illustrates the
problem you are having, it is impossible to say anything.
Sinan.
------------------------------
Date: Tue, 21 Oct 2003 15:46:43 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <20031021114710.504263f7.jwillmore@remove.adelphia.net>
On 21 Oct 2003 03:53:24 -0700
stewart@webslave.dircon.co.uk (stew dean) wrote:
> This is not a pure Perl problem but is to do with the running of
> Perl on IIS.
>
> I now have two scripts that run without errors (I'm using strict)
> but, for some reason, will not display the simple 'Done!' page built
> into the script. Instead the server gives me 'The page cannot be
> displayed'.
>
> I have run it on a local IIS set up with no problems but on the main
> server I continue to get this error. As I have no error messages
> other than page not displayed I'm not sure what I can tweak to get
> it to work. Maybe there's an error log I could look at?
This questions begs one to ask - "Did you read the documentation for
IIS?". Errors from your script _should_ be there for you to examine.
>
> I need to get a HTML page displayed at the end so I can then do
> futher steps but so far cannot.
>
> I'm running ActiveState Perl 5.8 with IIS 5 on a Windows 2000 box.
>
> Any help appreciated.
Please start by RTM :-) Also, run the script at the command line.
Any errors should show there - and be identical (with all things being
equal) to the error messages in the error log.
HTH
--
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 ...
In English, every word can be verbed. Would that it were so in
<our programming languages.
------------------------------
Date: 21 Oct 2003 09:24:07 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <3ee08638.0310210824.7cbb6646@posting.google.com>
stewart@webslave.dircon.co.uk (stew dean) wrote in message news:<2b68957a.0310210253.38464359@posting.google.com>...
> I now have two scripts that run without errors (I'm using strict) but,
> for some reason, will not display the simple 'Done!' page built into
> the script. Instead the server gives me 'The page cannot be
> displayed'.
Perhaps the server is not configured to run scripts? Or, if you know
that the scripts are running, the page won't display, you must have a
problem with formatting (maybe you're not sending the "text/html"
prologue?).
In that case, try shift-clicking the link that launches the scripts,
so you can save the output to a file, then peruse the file. Name it
with a .html extension and try to load it directly.
------------------------------
Date: 21 Oct 2003 08:26:26 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Quick Perl question
Message-Id: <3ee08638.0310210726.44676969@posting.google.com>
Anand <some@one.com> wrote in message news:<OcUkb.4571$8x2.2622961@newssrv26.news.prodigy.com>...
> (fork() || die "Cannot fork: $!") && exit;
Abigail was using the // operator, which is available as an extension,
but will be part of the core distribution in 5.10.0
You are using the ordinary || operator. The difference is that //
checks for definedness, not truth. To get that behavior, you need:
(defined(fork()) || die "Cannot fork: $!") && exit;
------------------------------
Date: Tue, 21 Oct 2003 11:33:36 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Quick Perl question
Message-Id: <3F9551D0.9040702@gwu.edu>
Abigail wrote:
> Anand (some@one.com) wrote on MMMDCCII September MCMXCIII in
> <URL:news:OcUkb.4571$8x2.2622961@newssrv26.news.prodigy.com>:
> ** I tried this but doesn't work. Could you please tell me where is glitch.
>
> Not if you top post.
>
And not if you can't say a) what you expected it to do and b) what
it *did* do. "It doesn't work" is not an adequate description of
your problem.
Chris Mattern
------------------------------
Date: Tue, 21 Oct 2003 15:34:42 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Quick Perl question
Message-Id: <mmclb.9456$PZ1.6832@nwrdny03.gnilink.net>
Roy Johnson <rjohnson@shell.com> wrote:
> Anand <some@one.com> wrote in message news:<OcUkb.4571$8x2.2622961@newssrv26.news.prodigy.com>...
> > (fork() || die "Cannot fork: $!") && exit;
>
> Abigail was using the // operator, which is available as an extension,
> but will be part of the core distribution in 5.10.0
>
> You are using the ordinary || operator. The difference is that //
> checks for definedness, not truth. To get that behavior, you need:
> (defined(fork()) || die "Cannot fork: $!") && exit;
You actually need
defined (my $pid = fork) or die "Cannot fork: $!";
exit if $pid;
Your version exits in the child as well...
--
Steve
------------------------------
Date: Tue, 21 Oct 2003 15:20:05 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Rookie: Constructing a large SQL INSERT statement
Message-Id: <20031021112037.03be89e9.jwillmore@remove.adelphia.net>
On Tue, 21 Oct 2003 00:54:44 +0200
Tore Aursand <tore@aursand.no> wrote:
> On Mon, 20 Oct 2003 09:43:53 -0700, nobull wrote:
> >> $stInsert->finish();
>
> > Unnecessarly calling finish() on DBI statement handles is, IMHO, a
> > bad habit.
>
> Really? Hmm. I started using DBI about 5 years ago, and I remember
> having a problem with "something" which didn't go away until I added
> the call to those finish() methods.
>
> Anyway. Why is it bad? I still go for the "slow, but safe"
> approach when programing, and find myself constantly doing
> prepare(), execute() and finish() even when a do() would have been
> enough.
For the record - it's not _required_ to use 'finish' or 'disconnect',
but it's also not frowned upon.
The reason it's not _required_ is simple - once the script ends, the
database object is torn down - taking the database connection with it.
To 'finish' and 'disconnect' is redundant. However, you may want to
tear a connection down _before_ the script finishes - which is why the
methods are available.
So - it's 6 of one, half-dozen of another.
HTH
--
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 ...
Real programmers don't bring brown-bag lunches. If the vending
<machine doesn't sell it, they don't eat it. Vending machines
<don't sell quiche.
------------------------------
Date: 21 Oct 2003 08:45:24 -0700
From: qazmlp1209@rediffmail.com (qazmlp)
Subject: Re: rsh & perl -Directory creation not possible
Message-Id: <db9bbf31.0310210745.5c7c926b@posting.google.com>
"Tintin" <me@privacy.net> wrote in message news:<bn336u$r9k3k$1@ID-172104.news.uni-berlin.de>...
> "qazmlp" <qazmlp1209@rediffmail.com> wrote in message
> news:db9bbf31.0310210142.1b5acfed@posting.google.com...
> > I have a perl script which creates a directory in the local machine.
> > But, if I call this script from the remote machine using rsh, the
> > directory is not created. And there is no error message reported. Why
> > is that so ?
> >
> > What is the remedy for this ?
>
> Does your script have something like?
>
> mkdir '/path/to/dir' or die "Can not mkdir /path/to/dir $!\n";
>
> If not, why not?
I have mkdir command in the script.
When the rsh was executed with 'mkdir' directly, it worked and the
directory was created. But, when the perl script(containing mkdir) was
executed, it did not work.
------------------------------
Date: 21 Oct 2003 09:18:30 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: rsh & perl -Directory creation not possible
Message-Id: <3ee08638.0310210818.7810c15e@posting.google.com>
qazmlp1209@rediffmail.com (qazmlp) wrote in message news:<db9bbf31.0310210142.1b5acfed@posting.google.com>...
> I have a perl script which creates a directory in the local machine.
It is better to post the relevant chunks of code than merely to
describe them. In Perl, There Is More Than One Way To Do It, and there
may be a problem with the Way you have chosen.
------------------------------
Date: 21 Oct 2003 08:56:10 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Setting config file using constant
Message-Id: <3ee08638.0310210756.79757dae@posting.google.com>
Tony <tony@spamme.com> wrote in message news:<20031021154850.63746a82.tony@spamme.com>...
> print "Admin Name: " . $Package::Config::ADMIN_NAME . "\n";
>
> Why this doesn't work? Please help, thanks very much.
The answer is that constants are not variables, and so are not
referenced as variables. Drop the $ from your reference, and you will
get what you expect.
perldoc constant
------------------------------
Date: 21 Oct 2003 08:22:18 -0700
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Use in if..elsif
Message-Id: <3ee08638.0310210722.4ebe4e24@posting.google.com>
"Andrey" <smario@rol.ru> wrote in message news:<bn32i8$51s$1@news.rol.ru>...
> For example (from code snippets below) if I call edit_info it makes
> My::Info and My::Setting to be used and I can't use global variables in
> edit_info, only in last elsif statement (change_settings).
> Use of global variables is critical for this code.
> I've read modperl, modperlib, Exporter but didn't find any solution.
> Can anyone suggest me someting?
Documentation for "use" says:
If you don't want your namespace altered, explicitly
supply an empty list:
use Module ();
That is exactly equivalent to
BEGIN { require Module }
You might want to change the modules so that they don't export
variables, if it is up to you. Otherwise, only import the functions:
use My::Info qw(edit_info);
then refer to the variables, when you need to, with explicit package
names. Alternatively, you can refer to globals explicitly as
$::varname
I hope this answers the question you were asking.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5691
***************************************