[24825] in Perl-Users-Digest
Perl-Users Digest, Issue: 6976 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 8 18:12:13 2004
Date: Wed, 8 Sep 2004 15:10:14 -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 Wed, 8 Sep 2004 Volume: 10 Number: 6976
Today's topics:
perl open function for size bigger than 2 Gig (Peng Yue)
Re: perl open function for size bigger than 2 Gig <nobull@mail.com>
Re: perl open function for size bigger than 2 Gig <Joe.Smith@inwap.com>
Re: perl open function for size bigger than 2 Gig <gifford@umich.edu>
POD-Templates Bastian.Zacher@aspect-online.de
Re: POD-Templates <mritty@gmail.com>
Re: printing code references (M.J.T. Guy)
Re: RE-Redirecting STDOUT (dan baker)
Re: RE-Redirecting STDOUT <emschwar@pobox.com>
Re: RE-Redirecting STDOUT <Joe.Smith@inwap.com>
Re: RE-Redirecting STDOUT <Joe.Smith@inwap.com>
Re: RE-Redirecting STDOUT (J. Romano)
Re: Replacing Ampertsand in cgi url <nobull@mail.com>
Re: Replacing Ampertsand in cgi url <Joe.Smith@inwap.com>
Re: Replacing Ampertsand in cgi url <flavell@ph.gla.ac.uk>
Re: Replacing Ampertsand in cgi url (J. Romano)
Re: Replacing Ampertsand in cgi url (JR)
Socket holding pattern (Gordon)
Re: Socket holding pattern (Anno Siegel)
Sybase DBI Returned data query Rob.Buxton@wcc.govt.nz
System call not acting as expected <sorry@no.spam>
Re: System call not acting as expected <emschwar@pobox.com>
Re: System call not acting as expected <sorry@no.spam>
Re: System call not acting as expected <someone@example.com>
Re: Xah Lee's Unixism <kkt@drizzle.com>
Re: Xah Lee's Unixism <cbfalconer@yahoo.com>
Re: Xah Lee's Unixism <firstname@lastname.pr1v.n0>
Re: Xah Lee's Unixism <spam@nimblegen.com>
Re: Xah Lee's Unixism <jeff@ccvcorp.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Sep 2004 09:56:47 -0700
From: peng.yue@gmail.com (Peng Yue)
Subject: perl open function for size bigger than 2 Gig
Message-Id: <3436affa.0409080856.54dc7ad1@posting.google.com>
Hi,
I have problem with open function. It can not open file with size
bigger than 2 Gig. If I open a file to write, when it reach 2 Gig,
file size will never increase. It is a unix system and I have no
problem to make file with bigger than 2 Gig. I can use cat to append a
big file. For example:
cat a.file >> b.file (b.file is already more than 2 gig)
I found one old post in this group said there is no file size
limitation on perl
http://groups.google.com/groups?q=perl+4+gig&hl=en&lr=&ie=UTF-8&selm=0BFEE4828427A0A6.7CBECF8D63941C4A.488E601871A4F67A%40lp.airnews.net&rnum=1
It seems there is for my case.
Any thought about this?
Peng
------------------------------
Date: Wed, 08 Sep 2004 18:17:07 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: perl open function for size bigger than 2 Gig
Message-Id: <chneii$2jp$1@sun3.bham.ac.uk>
Peng Yue wrote:
> I have problem with open function. It can not open file with size
> bigger than 2 Gig. If I open a file to write, when it reach 2 Gig,
> file size will never increase. It is a unix system and I have no
> problem to make file with bigger than 2 Gig. I can use cat to append a
> big file. For example:
> cat a.file >> b.file (b.file is already more than 2 gig)
Rebuild perl with large file support (a compile time option).
Most new binary distributions of Perl are built this way. So you may
want to get a newer Perl binary from your OS vendor.
------------------------------
Date: Wed, 08 Sep 2004 17:47:14 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: perl open function for size bigger than 2 Gig
Message-Id: <CAH%c.2660$LT5.1552@attbi_s52>
Peng Yue wrote:
> problem to make file with bigger than 2 Gig.
> I found one old post in this group said there is no file size
> limitation on perl
> http://groups.google.com/groups?q=perl+4+gig&hl=en&lr=&ie=UTF-8&selm=0BFEE4828427A0A6.7CBECF8D63941C4A.488E601871A4F67A%40lp.airnews.net&rnum=1
You misunderstood that post. There was a 32-bit limit; it has been fixed for
some time now. It appears that the version of perl you're using was not
compiled with large file support. You'll need to upgrade to a more recent
version, or recompile the old version from sources with the right options.
Systems that handle files greater than 2 Gig have settings like this:
linux% perl -V | egrep -i 'LARGE|FILE'
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
cc='cc', ccflags ='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
cppflags='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
Compile-time options: USE_LARGE_FILES
-Joe
------------------------------
Date: Wed, 08 Sep 2004 14:53:55 -0400
From: Scott W Gifford <gifford@umich.edu>
Subject: Re: perl open function for size bigger than 2 Gig
Message-Id: <qszllfkwq0s.fsf@mspacman.gpcc.itd.umich.edu>
peng.yue@gmail.com (Peng Yue) writes:
> Hi,
> I have problem with open function. It can not open file with size
> bigger than 2 Gig. If I open a file to write, when it reach 2 Gig,
> file size will never increase. It is a unix system and I have no
> problem to make file with bigger than 2 Gig. I can use cat to append a
> big file. For example:
> cat a.file >> b.file (b.file is already more than 2 gig)
As others have said, probably you need to recompile Perl, or else find
a new copy from your vendor.
But if you can't, an easy trick is to just pipe the output to/from a
program that can address large files. For example:
open(F,"| cat >/tmp/bigfile")
or die "error starting cat: $!\n";
print F "x"
for (1..2**32+1);
close(F)
or die "error closing cat: $!\n";
(untested, but you get the idea). I used to have a Solaris system
where I had to do this, for various reasons. :)
----ScottG.
------------------------------
Date: Wed, 8 Sep 2004 15:18:23 +0000 (UTC)
From: Bastian.Zacher@aspect-online.de
Subject: POD-Templates
Message-Id: <chn7rv$rfl$1@news.f.de.plusline.net>
Hello NG,
I'm actually exploring the perl-documentation via POD. It's nice and easy
to improve the code. While exploring
and writing own PODs, I just want to know if it's possible to work with
templates.
The design of most PODs is the same and my doc's should also be identical.
But I don't want to write the framework
over and over again.
The easiest way, I think, is to write a text-pod and pipe it into the
source. Maybe there's a "pod"-buildin?
How do you manage this?
Thanks,
bastian
------------------------------
Date: Wed, 08 Sep 2004 15:51:51 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: POD-Templates
Message-Id: <rUF%c.5343$dC4.4008@trndny06>
<Bastian.Zacher@aspect-online.de> wrote in message
news:chn7rv$rfl$1@news.f.de.plusline.net...
> I'm actually exploring the perl-documentation via POD. It's nice and
easy
> to improve the code. While exploring
> and writing own PODs, I just want to know if it's possible to work
with
> templates.
> The design of most PODs is the same and my doc's should also be
identical.
> But I don't want to write the framework
> over and over again.
>
> The easiest way, I think, is to write a text-pod and pipe it into the
> source. Maybe there's a "pod"-buildin?
Are you trying to write a POD for your own new module? If that's the
case, allow me to suggest Randal Schwartz's _Learning Perl Objects,
References, and Modules_. I just finished re-reading it a week ago, so
the material is relatively fresh on my mind - which made your post jump
out a bit. The last 2 or 3 chapters of the book all deal with writing
your own modules, documenting them, and testing them. Within these
chapters, it is suggested to use the program h2xs which comes with a
standard Perl installation. Running this command will give you the
directories and templates for all files needed to create a distribution.
This includes the skeleton POD included within the .pm file. This
serves as a basic template.
If this is not what you're looking for, carry on. :-)
Paul Lalli
------------------------------
Date: 8 Sep 2004 16:49:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: printing code references
Message-Id: <chnd65$n53$1@pegasus.csx.cam.ac.uk>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>Stuart Kendrick <skendric@fhcrc.org> wrote in comp.lang.perl.misc:
>>
>> I would like to see "&foo" instead of "&CODE(0x815bed0)".
>
>You can't. A sub can be anonymous, it can also be reachable through
>more than one name. In the first case, there simply is no name, in
>the second, which one should it print?
You can, actually - the debugger manages it. It just makes up a name
for anon subs:
DB<1> sub a { print "Hello" }
DB<2> $a = \&a
DB<3> x $a
0 CODE(0x31f178)
-> &main::a in (eval 6)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2-2
DB<4> $a = sub { print "Goodbye" }
DB<5> x $a
0 CODE(0x336c30)
-> &main::__ANON__[(eval 10)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2] in (eval 10)[/home/mjtg/perl-5.8.1-RC4/lib/perl5db.pl:618]:2-2
DB<6>
To see how the trick is performed, rummage in the source of the debugger.
Mike Guy
------------------------------
Date: 8 Sep 2004 10:16:04 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: RE-Redirecting STDOUT
Message-Id: <13685ef8.0409080916.6f88ac56@posting.google.com>
aisarosenbaum@yahoo.com wrote in message news:<e3394f73.0409020924.300957e9@posting.google.com>...
> No I'm not a stuttering typist. ;^)
>
> I'm in the pecular position of working in an environment in which
> STDOUT has been rudely redirected by a script (A) that runs my
> scripts (B). I want to take STDOUT back without knowing the
> handle to which it was redirected. I've found a lot of advise
> on redirecting STDOUT, but I need to re-redirect it back to the
> console from 'B' without hacking 'A'.
> -------------------
you should be able to CLOSE STDOUT and re-OPEN it to a file or the
screen or wherever you want.
d
------------------------------
Date: Wed, 08 Sep 2004 11:30:14 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: RE-Redirecting STDOUT
Message-Id: <etoy8jkpt21.fsf@wilson.emschwar>
botfood@yahoo.com (dan baker) writes:
> aisarosenbaum@yahoo.com wrote in message news:<e3394f73.0409020924.300957e9@posting.google.com>...
>> No I'm not a stuttering typist. ;^)
>>
>> I'm in the pecular position of working in an environment in which
>> STDOUT has been rudely redirected by a script (A) that runs my
>> scripts (B). I want to take STDOUT back without knowing the
>> handle to which it was redirected. I've found a lot of advise
>> on redirecting STDOUT, but I need to re-redirect it back to the
>> console from 'B' without hacking 'A'.
>> -------------------
>
> you should be able to CLOSE STDOUT and re-OPEN it to a file or the
> screen or wherever you want.
Well, that's the question, innit? How to figure out what STDOUT used
to be, before the environment redirected it. You can't just open
/dev/tty, because that might not have been where it was pointed. The
only way I can figure is for this environment to provide a global or
package-local variable that holds the original STDOUT, and re-open
STDOUT to it.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 08 Sep 2004 17:57:22 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: RE-Redirecting STDOUT
Message-Id: <6KH%c.132805$9d6.39561@attbi_s54>
dan baker wrote:
>>I'm in the pecular position of working in an environment in which
>>STDOUT has been rudely redirected by a script (A) that runs my
>>scripts (B). I want to take STDOUT back without knowing the
>>handle to which it was redirected. I've found a lot of advise
>>on redirecting STDOUT, but I need to re-redirect it back to the
>>console from 'B' without hacking 'A'.
>
> you should be able to CLOSE STDOUT and re-OPEN it to a file or the
> screen or wherever you want.
That is fine for redirecting STDOUT to somewhere else for the duration.
It does not handle the case of temporarily redirecting STDOUT somwhere
else and then re-pointing STDOUT back to where it was going originally.
(It may have been going to a pipe, a file, or something else that was
not connected to the terminal.)
-Joe
------------------------------
Date: Wed, 08 Sep 2004 18:01:06 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: RE-Redirecting STDOUT
Message-Id: <CNH%c.401858$%_6.47608@attbi_s01>
aisarosenbaum@yahoo.com wrote:
> I'm in the pecular position of working in an environment in which
> STDOUT has been rudely redirected by a script (A) that runs my
> scripts (B). I want to take STDOUT back without knowing the
> handle to which it was redirected. I've found a lot of advise
> on redirecting STDOUT, but I need to re-redirect it back to the
> console from 'B' without hacking 'A'.
perldoc -f open
Look for the section marked 'Here is a script that saves,
redirects, and restores "STDOUT" and "STDERR" using various methods:'.
-Joe
------------------------------
Date: 8 Sep 2004 14:10:47 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: RE-Redirecting STDOUT
Message-Id: <b893f5d4.0409081310.24e3e609@posting.google.com>
aisarosenbaum@gmail.com (aisarosenbaum) wrote in message news:<d844a2d1.0409071206.5bf19143@posting.google.com>...
> > >
> > > I'm in the pecular position of working in an environment in which
> > > STDOUT has been rudely redirected by a script (A) that runs my
> > > scripts (B). I want to take STDOUT back without knowing the
> > > handle to which it was redirected. I've found a lot of advise
> > > on redirecting STDOUT, but I need to re-redirect it back to the
> > > console from 'B' without hacking 'A'.
>
> Thanks, this works:
>
> open( STDOUT, ">/dev/tty" );
>
> Any ideas for a MS-portable solution?
Dear Aisa,
On DOS/Win32 platforms, try:
open(STDOUT, ">CON") or warn $!;
Hope this helps (and works!).
-- Jean-Luc
------------------------------
Date: Wed, 08 Sep 2004 18:00:23 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <chndj8$21p$1@sun3.bham.ac.uk>
Jean wrote:
> I have some urls in an HTML page that have the amperstand sign (&) in
> them, and I want to change only these amperstand into %26.
>
> For example:
>
> <a href="cgi-bin/test.cgi?var1=1&var=2">Bob & Paul</a> & Steve.
>
> Should become:
>
> <a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
Not this thia has anything to do woith perl but I very much doubt you
actually want to do this. A %26 in a URL query string will not act as
an agrument delimiter - it will act as a literal ambersand in the data.
You want a literal ampersand in the URL which will be interpreted as a
delimiter. To get a literal ampersand in the URL then in HTML this must
be encoded as an entity & (or a numeric entity if you prefer).
You probably should duck the whole issue an use a semi-colon instead.
------------------------------
Date: Wed, 08 Sep 2004 17:35:46 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <SpH%c.401692$%_6.199951@attbi_s01>
Jean wrote:
> <a href="cgi-bin/test.cgi?var1=1&var=2">Bob & Paul</a> & Steve.
>
> Should become:
>
> <a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
No, it should not.
"cgi-bin/test.cgi?var1=1&var=2" should remain as is, or be converted to
"cgi-bin/test.cgi?var1=1;var=2", otherwise your URL won't work.
Do you, perhaps, have a beginner-written or buggy test.cgi?
-Joe
------------------------------
Date: Wed, 8 Sep 2004 20:20:08 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <Pine.LNX.4.61.0409082008570.22346@ppepc56.ph.gla.ac.uk>
Not that it's a Perl issue, but...
On Wed, 8 Sep 2004, Joe Smith wrote:
> > <a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
>
> No, it should not.
Agreed.
> "cgi-bin/test.cgi?var1=1&var=2" should remain as is,
No! - making the obvious assumptions about context, if this variant is
used then the query string in the "URI attribute value" should read
var1=1&var=2 , or its equivalent (&). See:
http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.2
(which re-iterates a piece of advice that was in RFC1866 already)
> or be converted to "cgi-bin/test.cgi?var1=1;var=2",
Provided that the script supports this, yes (CGI.pm supports either
delimiter, as indeed it must if it's to handle real forms submission
as well as handling URLs composed according to B.2.2).
> otherwise your URL won't work.
Well, href="cgi-bin/test.cgi?var1=1&var=2" might give an impression
of working, but it's still broken, and will cause the thing to
fail HTML syntax validation.
The amusing this about this (assuming HTML) is that it's precisely
when it -doesn't- fail syntax validation, that it stops even giving an
impression of working: my example would be ?print=yes©=3 (results
of actual browser tests are on a web page of mine, but that's OT
here).
regards
------------------------------
Date: 8 Sep 2004 12:32:00 -0700
From: jl_post@hotmail.com (J. Romano)
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <b893f5d4.0409081132.2468cc16@posting.google.com>
jeanjerome@operamail.com (Jean) wrote in message news:<34ac455.0409080241.195d5723@posting.google.com>...
>
> I have been trying this for hours without luck so far... Needless to
> say my regular expression skills are bad...
>
> I have some urls in an HTML page that have the amperstand sign (&) in
> them, and I want to change only these amperstand into %26.
>
> For example:
>
> <a href="cgi-bin/test.cgi?var1=1&var=2">Bob & Paul</a> & Steve.
>
> Should become:
>
> <a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
Dear Jean,
Try the regular expression s/\b(href="[^"]*)&/$1%26/i, with this
line:
1 while $content =~ s/\b(href="[^"]*)&/$1%26/i;
The regular expression will replace the first "&" symbol in an
href-quoted tag. The "while" loop exists in case there are more than
one "&" symbols in an href tag, like this:
<a href="test.cgi?var1=1&var2=2&var3=3">Bob & Paul</a> & Steve.
That way, it will keep looping until it has no more href "&" symbols
to replace (instead of stopping after the first one).
I hope this helps, Jean.
-- Jean-Luc
------------------------------
Date: 8 Sep 2004 14:25:26 -0700
From: jrolandumuc@yahoo.com (JR)
Subject: Re: Replacing Ampertsand in cgi url
Message-Id: <b386d54b.0409081325.1b9dad70@posting.google.com>
> I have been trying this for hours without luck so far... Needless to
> say my regular expression skills are bad...
>
> I have some urls in an HTML page that have the amperstand sign (&) in
> them, and I want to change only these amperstand into %26.
>
> For example:
>
> <a href="cgi-bin/test.cgi?var1=1&var=2">Bob & Paul</a> & Steve.
>
> Should become:
>
> <a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
>
> Jean
Jean,
A far less than perfect solution might be something such as the below
script. I'm sure someone will point out the problems with this
approach and provide a much better solution, but until then, this may
get you started. It at least appears to provide the correct output.
Good luck.
JR
#!/perl -w
use strict;
my ($hyper, $link) =
qq!<a href="cgi-bin/test.cgi?var1=1&var=2">Bob & Paul</a> &
Steve.!
=~ /^(<.*?>)(.*)$/;
$hyper =~ s/&/%26/g;
print $hyper.$link;
=pod
actual output:
<a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
desired output:
<a href="cgi-bin/test.cgi?var1=1%26var=2">Bob & Paul</a> & Steve.
=cut
------------------------------
Date: 8 Sep 2004 12:48:10 -0700
From: clemmons@gmail.com (Gordon)
Subject: Socket holding pattern
Message-Id: <cd939529.0409081148.7236eed3@posting.google.com>
I've written a non-forking server using IO::Socket / IO::Select
based on Cookbook recipe 17.3. I need the ability to "quietly"
restart the server without dropping the connections. Currently
I'm using the hackish method of removing the 'use'd modules and
reloading them but that doesn't allow the core code to be
reloaded and I would prefer to have a clean start/stop anyway.
If I setup a separate 'holding' server on an alternate port,
does anyone know of a way to switch the connections over to it?
I would like to plug the connections into this holding server
while the main server reboots, then reconnect them.
Any tips/pointers/advice would be greatly appreciated. Thanks.
------------------------------
Date: 8 Sep 2004 21:17:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Socket holding pattern
Message-Id: <chnstl$sf6$1@mamenchi.zrz.TU-Berlin.DE>
Gordon <clemmons@gmail.com> wrote in comp.lang.perl.misc:
> I've written a non-forking server using IO::Socket / IO::Select
> based on Cookbook recipe 17.3. I need the ability to "quietly"
> restart the server without dropping the connections. Currently
> I'm using the hackish method of removing the 'use'd modules and
> reloading them but that doesn't allow the core code to be
> reloaded and I would prefer to have a clean start/stop anyway.
>
> If I setup a separate 'holding' server on an alternate port,
> does anyone know of a way to switch the connections over to it?
> I would like to plug the connections into this holding server
> while the main server reboots, then reconnect them.
If the duration of each connection is limited, an "overlapping restart"
is a possibility.
On a signal (or something), the server forks and execs a new copy.
It also ceases to accept new connections, but continues serving
the old ones. When the last connection is gone, it dies. All
new requests are served by the new process.
If you have unlimited connection time, and can't afford to break
long-lasting ones, this simple scheme won't work. Sketchy as it
is, it may well not work for other reasons.
Anno
------------------------------
Date: Thu, 09 Sep 2004 09:22:50 +1200
From: Rob.Buxton@wcc.govt.nz
Subject: Sybase DBI Returned data query
Message-Id: <6stuj0p9uu257impt3tddevi6usmh924i3@4ax.com>
Hi All,
I've been struggling with this for a while so I'm hoping there'll will
be someone who knows what I'm doing wrong.
Perl 5.8.4, DBI 1.43, Sybase DBD 1.04. on Windows 2003.
The script I'm running changes a Users Password in a Sybase Database.
It's driven from a Web Page (IIS 6.0)
The database connection works fine and the actual sth->execute does
change the password via the sp_password stored procedure.
Snippet of code below.
my $query="execute sp_password '$PASSWORD', '$pass', '$name'";
my $sth = $dbh->prepare(${query});
$sth->execute;
The problem is the sp_password generates a message:
"Password correctly set." which seems to upset the Web Page as all I
get is a CGI Error - The specified CGI application misbehaved by not
returning a complete set of HTTP headers.
If I run the script locally, it works fine.
Is there anyway of catching the returned data from the sth->execute
command before it hits the Web Server or of suppressing any returned
data?
Many thanks in advance,
Rob
------------------------------
Date: Wed, 8 Sep 2004 11:32:08 -0700
From: "Mike Kohary" <sorry@no.spam>
Subject: System call not acting as expected
Message-Id: <chnj73$jla$0@pita.alt.net>
Relative beginner here, but not totally inexperienced (and am quite
comfortable with Unix). In my script, I have the following line:
system ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
The idea is to ls -d some directories to the file logfile_dirs.
$log_location is an assigned variable, and $instance is assigned via user
input. The problem is that this line doesn't work, though I'd fully expect
it would. I even added this line to make sure I was telling it to do the
right thing:
print ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
The result of this line confirms that it is generating exactly the command
that I want, and if I copy and paste the printed line, it performs as
expected. So, why doesn't the system call perform exactly the same way?
Not only doesn't it redirect the output to logfile_dirs (or even create the
file), but if I remove the redirection altogether, it still doesn't work -
no output to the screen.
Can anyone spot what's wrong? Let me know if I need to provide more info -
thanks!
Mike
------------------------------
Date: Wed, 08 Sep 2004 13:00:54 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: System call not acting as expected
Message-Id: <etobrggpoux.fsf@wilson.emschwar>
"Mike Kohary" <sorry@no.spam> writes:
> Relative beginner here, but not totally inexperienced (and am quite
> comfortable with Unix). In my script, I have the following line:
>
> system ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
Please read:
perldoc -f system
In general, if a function isn't doing what you expect, you should read
the documentation for it first via 'perldoc -f $function', before
posting here. If you had, you would have read (in the first
paragraph, no less!):
If there is more than one argument in LIST, or if LIST is an array
with more than one value, starts the program given by the first
element of the list with arguments given by the rest of the list.
If there is only one scalar argument, the argument is checked for
shell metacharacters, and if there are any, the entire argument is
passed to the system's command shell for parsing (this is "/bin/sh
-c" on Unix platforms, but varies on other platforms).
You seem to be expecting the latter behaviour, but because you're
using commas, you're creating a list with more than one value, and
thus trying getting the former. Why are you using commas there
anyhow? Why not use the string concatenation operator:
system("ls -d ".$log_location."*_instance_".$instance." > logfile_dirs");
or just interpolate directly into the command line (this is the most
perlish solution that uses system):
system("ls -d $log_location*_instance_$instance > logfile_dirs");
or better yet
my @logfile_dirs = `ls -d $log_location*_instance_$instance`;
Of course, this last only works if the next step is to read the file
logfile_dirs into an array, which seems likely, but I don't know your
application.
> The idea is to ls -d some directories to the file logfile_dirs.
You might also look into opendir/readdir to iterate through
directories; that is generally more portable, and will save you from
other possible sillinesses, like when someone aliases 'ls' to 'ls
--color', exports the alias, and then runs your program. Then you get
all sorts of fun problems, like having to sort out terminal escape
sequences.
> I even added this line to make sure I was telling it to do the
> right thing:
>
> print ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
>
> The result of this line confirms that it is generating exactly the command
> that I want, and if I copy and paste the printed line, it performs as
> expected. So, why doesn't the system call perform exactly the same way?
Because system() works differently than print(). This is why, when
two functions don't behave the same, you should read the docs for both
of them to find out why.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 8 Sep 2004 12:17:49 -0700
From: "Mike Kohary" <sorry@no.spam>
Subject: Re: System call not acting as expected
Message-Id: <chnlsq$okm$0@pita.alt.net>
"Eric Schwartz" <emschwar@pobox.com> wrote in message
news:etobrggpoux.fsf@wilson.emschwar...
>
> Please read:
>
> perldoc -f system
>
> In general, if a function isn't doing what you expect, you should read
> the documentation for it first via 'perldoc -f $function', before
> posting here.
Thanks, I was unaware of that. Newbie alert! :)
> If you had, you would have read (in the first
> paragraph, no less!):
>
> If there is more than one argument in LIST, or if LIST is an array
> with more than one value, starts the program given by the first
> element of the list with arguments given by the rest of the list.
> If there is only one scalar argument, the argument is checked for
> shell metacharacters, and if there are any, the entire argument is
> passed to the system's command shell for parsing (this is "/bin/sh
> -c" on Unix platforms, but varies on other platforms).
>
> You seem to be expecting the latter behaviour, but because you're
> using commas, you're creating a list with more than one value, and
> thus trying getting the former. Why are you using commas there
> anyhow? Why not use the string concatenation operator:
>
> system("ls -d ".$log_location."*_instance_".$instance." > logfile_dirs");
>
> or just interpolate directly into the command line (this is the most
> perlish solution that uses system):
>
> system("ls -d $log_location*_instance_$instance > logfile_dirs");
>
> or better yet
>
> my @logfile_dirs = `ls -d $log_location*_instance_$instance`;
>
> Of course, this last only works if the next step is to read the file
> logfile_dirs into an array, which seems likely, but I don't know your
> application.
That's exactly right, and thanks for all the suggested alternatives - they
work perfectly of course. :)
> > The idea is to ls -d some directories to the file logfile_dirs.
>
> You might also look into opendir/readdir to iterate through
> directories; that is generally more portable, and will save you from
> other possible sillinesses, like when someone aliases 'ls' to 'ls
> --color', exports the alias, and then runs your program. Then you get
> all sorts of fun problems, like having to sort out terminal escape
> sequences.
Good idea - I didn't think of that either. I have so much to learn. Thanks
for all the help!
Mike
------------------------------
Date: Wed, 08 Sep 2004 19:40:13 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: System call not acting as expected
Message-Id: <xeJ%c.111596$A8.71467@edtnps89>
Mike Kohary wrote:
> Relative beginner here, but not totally inexperienced (and am quite
> comfortable with Unix). In my script, I have the following line:
>
> system ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
>
> The idea is to ls -d some directories to the file logfile_dirs.
> $log_location is an assigned variable, and $instance is assigned via user
> input. The problem is that this line doesn't work, though I'd fully expect
> it would. I even added this line to make sure I was telling it to do the
> right thing:
>
> print ("ls -d ",$log_location,"*_instance_",$instance," > logfile_dirs");
>
> The result of this line confirms that it is generating exactly the command
> that I want, and if I copy and paste the printed line, it performs as
> expected. So, why doesn't the system call perform exactly the same way?
> Not only doesn't it redirect the output to logfile_dirs (or even create the
> file), but if I remove the redirection altogether, it still doesn't work -
> no output to the screen.
>
> Can anyone spot what's wrong? Let me know if I need to provide more info -
> thanks!
system() can be used with *either* a string or a list, the string invocation
uses the shell and the list invocation does not. Since your example has shell
metacharacters (* and >) you have to use a string.
system( "ls -d $log_location *_instance_ $instance > logfile_dirs" ) == 0 or
die "system 'ls' failed: $?";
However, instead of using 'ls' from system() you should use perl's built-in
functions and operators.
open LOG, '>', 'logfile_dirs' or die "Cannot open 'logfile_dirs' $!";
opendir DIR, '.' or die "Cannot open the current directory: $!";
print LOG map "$_\n",
grep { $_ eq $log_location or $_ eq $instance or /_instance_$/ }
readdir DIR;
closedir DIR;
close LOG;
John
--
use Perl;
program
fulfillment
------------------------------
Date: 08 Sep 2004 09:44:25 -0700
From: Patrick Scheible <kkt@drizzle.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <tqmisaoiuc6.fsf@drizzle.com>
jmfbahciv@aol.com writes:
> It's apparently having the desired effect. The subject of
> the radio talk show last night was about the results of a poll
> where 41% of the people asked (New York state residents) believed
> that Bush and Co. knew that the WTC was going to be attacked and
> did nothing to prevent it.
They can have a nice chat with the 40-some-odd percent of the people
who think Saddam was working with al-Qaida...
-- Patrick
------------------------------
Date: Wed, 08 Sep 2004 17:59:40 GMT
From: CBFalconer <cbfalconer@yahoo.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <413F43AC.9D2088AF@yahoo.com>
jmfbahciv@aol.com wrote:
> Alan Balmer <albalmer@att.net> wrote:
>> CBFalconer <cbfalconer@yahoo.com> wrote:
>>> Alan Balmer wrote:
>>>>
>>>... snip ...
>>>>
>>>> I'm not a fan of Mr Hatch, but blaming him for the shuttle
>>>> disaster(s) is somewhat over the top. Why not blame President
>>>> Bush? That's the popular thing nowadays.
>>>
>>> Alright, if you insist. But is it really necessary? We can find
>>> adequate charges without reaching very hard.
>>
>> Then why are so many people reaching so hard?
>
> It's apparently having the desired effect. The subject of
> the radio talk show last night was about the results of a poll
> where 41% of the people asked (New York state residents) believed
> that Bush and Co. knew that the WTC was going to be attacked and
> did nothing to prevent it. The Bush-bashing is working. The
> Democrats are opening the city gates to the barbarians.
I deplore your tast in radio talk shows. It doesn't take much to
create a rabble rousing poll to increase ratings.
There is no need, nor cause, to impute Bush & Co. with
intrinsically evil intentions. It is quite enough to point to
their lack of capability, and bull headed 'revenge for daddy'
propensities. The state of the economy, unemployment, poverty
rate, medical care, deficit, death rate in Iraq (both of Americans
and Iraqis), abandonment of the Bin Laden hunt, abridgement of
civil liberties (as in the Patriot Act and the Gitmo gulag), poor
choice of companions (Halliburton and other political donors and
trough feeders, and the 'plausible deniability' of the Swiftboat
gang), irritation of allies, inability to deal with North Korea
(due to involvement with useless adventures), abandonment of
efforts towards a Palestinian peace, all spring to immediate mind.
Yes, we have had no experience with a Kerry administration, but we
have had far too much experience with a Bush administration.
--
"I'm a war president. I make decisions here in the Oval Office
in foreign policy matters with war on my mind." - Bush.
"If I knew then what I know today, I would still have invaded
Iraq. It was the right decision" - G.W. Bush, 2004-08-02
------------------------------
Date: Wed, 8 Sep 2004 20:43:17 +0200
From: Morten Reistad <firstname@lastname.pr1v.n0>
Subject: Re: Xah Lee's Unixism
Message-Id: <5sjnhc.bb81.ln@via.reistad.priv.no>
In article <413f049f$0$6914$61fed72c@news.rcn.com>, <jmfbahciv@aol.com> wrote:
>In article <p9qdnTnxTYDJR6PcRVn-pw@speakeasy.net>,
> rpw3@rpw3.org (Rob Warnock) wrote:
>>John Thingstad <john.thingstad@chello.no> wrote:
>>+---------------
>>| As you may know XP is not particularly good as a server.
>>....
>>| I would go for some Unix implementation (perhaps free-BSD)
>>| As a workstation XP seems OK.
>>| I hear a lot of complaints about XP's stability.
>>| Since I have not administered a XP network, yet, I cant comment on that.
>>| But in my personal experience it is a stable system.
>>| I frequently let my computer run 24 hrs. a day for more than a month
>>| without a need to reboot. So for me it is adequate.
>>+---------------
>>
>>*Only* a month?!? Here's the uptime for one of my FreeBSD boxes
>>[an old, slow '486]:
>>
>> % uptime
>> 2:44AM up 630 days, 21:14, 1 user, load averages: 0.06, 0.02, 0.00
>> %
>>
>>That's over *20* months!!
>
>I bet we can measure the youngster's age by the uptimes he boasts.
>>
>>
>>-Rob
>>
>>p.s. I remember the time back in the early 70's (at Emory Univ.) when
>>we called DEC Field Service to complain that our PDP-10 had an uptime
>>of over a year. Why were we complaining? Well, that meant that DEC Field
>>Service had failed to perform scheduled preventive maintenance (which
>>usually involved at least one power cycle)... ;-}
>
>One? Had to be two. FS was supposed to use their service pack
>as the system disk, not the customers!!! I believe that was
>true even in 1970. The dangers of smushing bits was too great.
But with a PM you had to do a cold start. All the disks had to be
spun down, filters changed, and they had to spin for an ungodly long
time after the filter change before heads could be enabled again. This
was to bring all the dust that was let loose in the process into the new
filters before heads went to fly over the platters again.
Also power supplies had to be checked for the dreaded capacitor
problems. Tape drives also had these. This was industry-wide
problems; and news from a few burned UPS'es the last couple of
months tell me that the capacitor problems are still with us.
It was a real accomplishment when we in 1988 could do a full
PM (Prime gear) without shutting down the system. All disks were
mirrored, and all power duplicated, so we shut down half of the
hardware and did PM on that; and took the other half next week.
SMD filters were used at a quite high rate; even inside well
filtered rooms. ISTR 6 months was a pretty long interval between PM's.
-- mrr
------------------------------
Date: Wed, 08 Sep 2004 16:32:34 -0500
From: Chuck Dillon <spam@nimblegen.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <chntno$ku1$1@grandcanyon.binc.net>
<Sorry for this off-topic post but I couldn't resist.>
CBFalconer wrote:
>
> There is no need, nor cause, to impute Bush & Co. with
> intrinsically evil intentions. It is quite enough to point to
> their lack of capability, and bull headed 'revenge for daddy'
You should consider investing some time in learning some civics. The
president has no power to wage war without a *mandate* from congress.
It's assinine to suggest that the administration could have tricked or
lied it's way into a war in Iraq. People like Sen. Byden (D) who are
now considered experts with more than enough experience in overseeing
our intelligence organization take the lead on criticizing the
administration. But Sen. Byden and the rest were briefed before they
voted and they had the experience to make their own judgements. They
chose to effectively declare war on Iraq.
There's no question the legislative branch declared war and the
administrative is prosecuting it. The only question is how the
politics plays out.
> propensities. The state of the economy, unemployment, poverty
> rate, medical care, deficit,
Yes there are economic cycles and we've been in a bit of a trough for
the past few years. There's nothing the government, nor any
administration, can do to significantly effect economic cycles. If it
can then the Clinton administration must have intentionally induced a
downturn for political purposes.
> death rate in Iraq (both of Americans
> and Iraqis),
But noticebly not in Chicago, L.A or anywhere else in "the great evil".
> abandonment of the Bin Laden hunt,
Capturing of OBL would be counterproductive. The problem won't go away
if he's caught but many people will assume it did.
> abridgement of
> civil liberties (as in the Patriot Act and the Gitmo gulag),
Back to civics 101, laws are created by the legislature. They also
have the power to revoke them if a problem is demonstrated. How many
U.S. citizens have been victimized? How many dead U.S. citizens does
it take to justify that victimization? Both numbers are quire small.
> poor
> choice of companions (Halliburton and other political donors and
That's just stupid. I'm sure the families of those Halliburton
employees who have died in Iraq and Afganistan would take issue with
you on this. Are you also leary of Clinton because his administration
contracted the same Halliburton subsidiaries in the Balkan conflict?
> trough feeders, and the 'plausible deniability' of the Swiftboat
> gang),
It would be astounding if there was no Veteran backlash in response to
Kerry's activities and statements after he came back from Vietnam. You
bring up Halliburton as if it were somehow on topic and then in the
next phrase suggest that legitimate angst against Kerry's anti-war
activies (with Kerry building his campaign on his Vietnam service) is
somehow invalid. Strange thought process.
> irritation of allies,
It seems to me that from a geo-political perspective it would be a bad
thing if 100% of non-Muslim/non-Arab/non-Middleeastern states followed
the lead of the U.S. in a seemingly rash response to 9/11. It seems
like it would be much better if there was an overwhelming (as there
was) response balanced by some strong dissention so that it didn't look
like a world war.
> inability to deal with North Korea
> (due to involvement with useless adventures),
Patience grasshopper. Just because CNN isn't "breaking news" on a
daily basis doesn't mean nothing's being done. North Korea is
extremely fragile economically. They're not in the position to demand
they're just trying to barter.
> abandonment of
> efforts towards a Palestinian peace, all spring to immediate mind.
You might not have noticed but on 9/11 the stakes were raised by about
an order of magnitude. They went up significantly again this weekend
in Beslan. As long as there are terrorist activities in "Palestine"
don't expect to see anyone giving ground.
>
> Yes, we have had no experience with a Kerry administration, but we
> have had far too much experience with a Bush administration.
>
We know...
- Kerry voted to effectively declare war on Iraq and still stands by
that vote, most of the time. He only quibbles about the details.
- Kerry has no more power to affect the economy than W.
- Kerry's administration would continue to contract with Haliburton
subsidiaries. There's no reason not to, there's no other company who
can do the jobs they contract to do.
-- ced
--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
------------------------------
Date: Wed, 08 Sep 2004 14:53:10 -0700
From: Jeff Shannon <jeff@ccvcorp.com>
Subject: Re: Xah Lee's Unixism
Message-Id: <10juvnrt88k4868@corp.supernews.com>
Chuck Dillon wrote:
>> abridgement of
>> civil liberties (as in the Patriot Act and the Gitmo gulag),
>
>
> [...] How many U.S. citizens have been victimized?
That's the problem -- we have *no* way of finding out, because part of
the Patriot Act is a gag rule that prevents the public from knowing how
it's used. It *may* be a small number, and we'd all like to think that
it is, but we really don't know.
> How many dead U.S. citizens does it take to justify that
> victimization? Both numbers are quire small.
Here there's a lot of room to disagree -- it's a tragedy when U.S.
citizens are killed, but it's an even greater tragedy when the entirety
of the U.S. loses its freedoms in the name of "security".
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety," as Benjamin Franklin said.
The Patriot Act takes away our liberty in the name of temporary safety.
We need better security than we had pre-9/11, certainly, but we can get
it with a much lower cost to our personal liberty than has come with the
Patriot Act. We *don't* need secret police investigations, secret
courts, and secret detentions for secret reasons.
Jeff Shannon
Technician/Programmer
Credit International
------------------------------
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 6976
***************************************