[24182] in Perl-Users-Digest
Perl-Users Digest, Issue: 6374 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 8 00:05:44 2004
Date: Wed, 7 Apr 2004 21:05:09 -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, 7 Apr 2004 Volume: 10 Number: 6374
Today's topics:
Re: [VERY OT] a linguistic question (.sig-related, xpos <cameronc@aplcenmp.apl.jhu.edu>
Re: [VERY OT] a linguistic question (.sig-related, xpos (John M. Gamble)
Re: Bug? perl says "Unknown Error" <abigail@abigail.nl>
Re: display Excel file in browser? (John McNamara)
Re: Filehandles Referenced with a Variable <emschwar@pobox.com>
Re: Perl and Internet Explorer <matthew.garrish@sympatico.ca>
Re: Perl neq Python <tore@aursand.no>
Re: Perl neq Python <bigal187.invalid@adexec.com>
Re: Perl neq Python <tore@aursand.no>
Re: problem with HangUP <aolblowz@yahoo.com>
Re: problem with HangUP <aolblowz@yahoo.com>
Question on refs inside hash (rocknmetal20)
Re: Question on refs inside hash <invalid-email@rochester.rr.com>
Re: scope again <invalid-email@rochester.rr.com>
Re: scoping, sig handlers, and labels <wherrera@lynxview.com>
Shell-escaping from perl <cs31504@hotmail.com>
Re: Shell-escaping from perl <xx087@freenet.carleton.ca>
Re: Shell-escaping from perl <Jon.Ericson@jpl.nasa.gov>
Re: Why does split operate over multiple lines in the a (Sara)
wrong exitstatus returned? <ppi_doesnt_like_@spam_inhis_email_searchy.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Apr 2004 11:09:34 -0400
From: "Cameron, Charles B. " <cameronc@aplcenmp.apl.jhu.edu>
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <407419AE.8040001@aplcenmp.apl.jhu.edu>
Michele Dondi wrote:
> I'm sorry for this OT, but these seemed to me the best NGs, amongst
> those that I subscribe, to ask this question, and I don't know where
> else I could do it.
>
> I like to gather witty cmts or otherwise interesting sentences from
> USENET posts to quote in .sigs: now I have a doubt about the
> preposition to use when citing the author, i.e. should I use
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
> or
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
> Michele
As I'm sure you'll soon see, this is a matter of opinion.
I would opt for "in" because you are quoting something "in" a posting, a usage very like a reference to something being "in a book" or "in a magazine article".
Those who opt for "on" will probably base their choice on the use of "on" in expressions like "on television", "on the radio", or "on the newswires".
Charles B. Cameron
------------------------------
Date: Thu, 8 Apr 2004 03:25:18 +0000 (UTC)
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: [VERY OT] a linguistic question (.sig-related, xposted)
Message-Id: <c52gmu$i3r$3@e250.ripco.com>
In article <90o770tpk731n8dev5rg1ihto441dlsbuv@4ax.com>,
Michele Dondi <bik.mido@tiscalinet.it> wrote:
>I'm sorry for this OT, but these seemed to me the best NGs, amongst
>those that I subscribe, to ask this question, and I don't know where
>else I could do it.
>
>I like to gather witty cmts or otherwise interesting sentences from
>USENET posts to quote in .sigs: now I have a doubt about the
>preposition to use when citing the author, i.e. should I use
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker in comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
>or
>
> > utterly stupid claim
> witty cmt
> - J. Random Hacker on comp.foo.bar, "Re: Fred Mbogo"
> ^^
>
>Michele
If it must be one or the other, I would pick "in." It is
a thing (the newsgroup) that has content (the messages).
However, i myself don't bother. Here's an example:
"See, I get grumpy when people put 'SA doesn't have to think' into a
sentence. Not that I don't appreciate the sentiment of making thing easy,
but having the SA conscious during some point of their career is a bonus."
Elaine Ashton, perl5-porters mailing list, 3 August 2001
--
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
------------------------------
Date: 07 Apr 2004 22:11:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Bug? perl says "Unknown Error"
Message-Id: <slrnc78v3o.aia.abigail@alexandra.abigail.nl>
Rafael Garcia-Suarez (rgarciasuarez@free.fr) wrote on MMMDCCCXLII
September MCMXCIII in <URL:news:slrnc4ordu.36l.rgarciasuarez@dat.local>:
,, Heinrich Mislik wrote in comp.lang.perl.misc :
,, > This is Bug.pm
,, >
,, > #--------------------
,, > use strict;
,, > use base Exporter;
,, >
,, > 1;
,, > #--------------------
,, >
,, > ~>perl -c Bug.pm
,, > Bareword "Exporter" not allowed while "strict subs" in use at Bug.pm line 2.
,, > Bug.pm had compilation errors.
,, >
,, > Is the expected error message, but:
,, >
,, >
,, > ~>perl -e 'use Bug'
,, > Unknown error
,, > Compilation failed in require at -e line 1.
,, > BEGIN failed--compilation aborted at -e line 1.
,, >
,, > is not very useful.
,,
,, Yes, this is a bug.
,, It's fixed in the current development version of perl.
,, I don't remember if the fix will be available in perl 5.8.4, though.
Not in RC1:
$ /opt/perl/5.8.4-RC1/bin/perl -e 'use Bug'
Unknown error
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Abigail
--
perl -le 's[$,][join$,,(split$,,($!=85))[(q[0006143730380126152532042307].
q[41342211132019313505])=~m[..]g]]e and y[yIbp][HJkP] and print'
------------------------------
Date: 7 Apr 2004 15:27:02 -0700
From: jmcnamara@cpan.org (John McNamara)
Subject: Re: display Excel file in browser?
Message-Id: <8cceb2da.0404071427.7b7e2b3f@posting.google.com>
Bing Du <bdu@iastate.edu> wrote:
> I've used Spreadsheet::WriteExcel to generate a spreadsheet. Now I
> need this spreadsheet to be viewable in web browsers.
> ...
>
> If I use the following code to load my.xls into $bindata, how can
> I display $bindata in its original spreadsheet format on the web?
In the examples directory of the Spreadsheet::WriteExcel distro there
is a program called cgi.pl that shows how to stream an Excel file to a
browser.
The Content-type/Content-Disposition headers in the program will also
work if you wish to stream an existing file.
John.
--
------------------------------
Date: Wed, 07 Apr 2004 17:39:47 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Filehandles Referenced with a Variable
Message-Id: <etoptajjr24.fsf@fc.hp.com>
Mike Flannigan <mikeflan@earthlink.net> writes:
> Eric Schwartz wrote:
>> Nope. By "extract $fh from the hash" he means
>>
>> my $fh = $handles{$state}
>>
>> You had the handle in the hash, now you have extracted it into $fh.
>> Comprende?
>
> Well, that would make a whole lot more sense to me, but I
> don't think that is what I did. Correct me if I'm wrong, but
> I don't see that in this code:
That's because the code you posted is what puts the filehandle into
the hash in the first place.
> foreach (@states) {
> my $fh; # Start with a scalar variable whose value is undef
> open $fh, '>', "$_.txt" or die "Cannot open $_.txt: $!";
> $handles{$_} = $fh; # open() magically makes $fh into a filehandle!
This line, right here is what does it. You have a filehandle in $fh.
You put it into a hash. Later on, you extract the filehandle from the
hash, and use it to print to. At least, I assume you do, since that
part of the code isn't posted here.
> }
>
> That perldoc perldata documentation posted by Myron
> kinda makes sense, but I still don't have a good grasp of
> anonymous filehandle or anonymous anything. I've
> accepted it as magic for the moment.
If you don't talk about what you don't understand, nobody can help you
understand it. If you can figure out what it is you don't understand
about that section of perldata, please post a question about it, and
maybe someone can help. And once you do understand it, feel free to
suggest changes to the documentation that could make it clearer.
-=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, 7 Apr 2004 20:40:22 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Perl and Internet Explorer
Message-Id: <Sb1dc.10025$BF2.848602@news20.bellglobal.com>
"Richard Morse" <remorse@partners.org> wrote in message
news:remorse-D191C2.14260907042004@plato.harvard.edu...
> In article <1xFcc.4987$BF2.609573@news20.bellglobal.com>,
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
>
> > "akaliel" <akaliel@streamflo.com> wrote in message
> > news:7123bc57.0404061154.595341a@posting.google.com...
> > > > Not sure if it will make any difference to IE, but might be worth a
try.
> > And
> > > > if it does work but blows up Netscape you could always detect the
> > browser
> > > > type and send the appropriate header.
> > > >
> > > > Matt
> > >
> > > That's the MIME type I'm using that managed to get it to partially
> > > work. Right clicking on the link will allow me to save it as a .ppt
> > > by default. However, left clicking on the link does nothing
> > > whatsoever. If I right click and say "Open in New Window" then just
> > > after the new window launches, it crashes.
> >
> > I assume you've already tried the following http header to specify a
default
> > filename?
> >
> > Content-Disposition: attachment; filename=[FILENAME]
>
> You might try Content-Disposition: inline; filename=... instead -- this
> may make the streaming work...
>
Good point. (From his reply, I think he figured it out on his own though.)
Matt
------------------------------
Date: Thu, 08 Apr 2004 02:11:03 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Perl neq Python
Message-Id: <pan.2004.04.07.22.12.20.683731@aursand.no>
On Wed, 07 Apr 2004 18:11:10 +0000, Berk Birand wrote:
> I have learned coding in Perl couple of weeks ago
> [...]
Are you saying that you learned Perl _in_ a couple of weeks? If so,
that's bullshit.
> Under what circumstances should I use Perl, Python or straight shell
> scripting?
If you _really_ know each of these programming languages/techniques, you
know what to use and when to use it.
--
Tore Aursand <tore@aursand.no>
"First, God created idiots. That was just for practice. Then He created
school boards." -- Mark Twain
------------------------------
Date: Wed, 7 Apr 2004 18:50:07 -0700
From: "187" <bigal187.invalid@adexec.com>
Subject: Re: Perl neq Python
Message-Id: <c52b4g$2ojns0$1@ID-196529.news.uni-berlin.de>
Tore Aursand wrote:
> On Wed, 07 Apr 2004 18:11:10 +0000, Berk Birand wrote:
> > I have learned coding in Perl couple of weeks ago
> > [...]
>
> Are you saying that you learned Perl _in_ a couple of weeks? If so,
> that's bullshit.
Geezus Smite, don't have to be so anal. Maybe he meant he learned Perl
as in the basics a few weeks. And for that matter, I've known people who
have picked up a language like this fairly quickly. If you are an
experienced programmer also with shell and Linux, and maybe with tolls
like sed and awk, Perl can be a fairly quick pick up, for the most part.
Maybe not the most advanced stuff but quite possibly the basics of it.
Whose to say this guy hasn't picked it up quickly? You never know who
has a nature nack for it.
> > Under what circumstances should I use Perl, Python or straight shell
> > scripting?
>
> If you _really_ know each of these programming languages/techniques,
> you know what to use and when to use it.
Re read his question. He never claimed to be an expert.
------------------------------
Date: Thu, 08 Apr 2004 06:03:30 +0200
From: Tore Aursand <tore@aursand.no>
Subject: Re: Perl neq Python
Message-Id: <pan.2004.04.08.02.54.00.941203@aursand.no>
On Wed, 07 Apr 2004 18:50:07 -0700, 187 wrote:
>>> I have learned coding in Perl couple of weeks ago
>>> [...]
>> Are you saying that you learned Perl _in_ a couple of weeks? If so,
>> that's bullshit.
> Geezus Smite, don't have to be so anal. Maybe he meant he learned Perl
> as in the basics a few weeks.
I just wanted to make sure that he knows the difference between knowing
Perl and _knowing_ Perl. I've been programming Perl for the last 6 years,
and I still have _a lot_ to learn.
>>> Under what circumstances should I use Perl, Python or straight shell
>>> scripting?
>> If you _really_ know each of these programming languages/techniques,
>> you know what to use and when to use it.
> Re read his question. He never claimed to be an expert.
I never said that, either. My point is still valid: If you _really_ know
a bunch of different languages, you automatically knows which language is
the best to solve the task(s) you have in front of you.
"The right tool for the right job", so to speak. Perl doesn't solve
everything in this world (it's close, though), and other languages fill in
where Perl isn't at its strongest.
--
Tore Aursand <tore@aursand.no>
"A teacher is never a giver of truth - he is a guide, a pointer to the
truth that each student must find for himself. A good teacher is
merely a catalyst." -- Bruce Lee
------------------------------
Date: Wed, 07 Apr 2004 19:37:11 -0400
From: lucas <aolblowz@yahoo.com>
Subject: Re: problem with HangUP
Message-Id: <hMCdnbvlp9s7Dend4p2dnA@golden.net>
Anno Siegel wrote:
> No.
>
> The code you show doesn't exit. If it exits for you, that happens in the
> code you don't show. We can't correct code we don't get to see.
>
the sub routine doesn't exit either. i know this because i run it at the
start of the program. And i know that the $SIG(HUP) shouldn't exit, but it
does. i put a 'print "DONE LOADING\N"; ' in the $SIG, as you can see, and
it is printed to screen, so the LoadFiles() returns properly.
$SIG{HUP} = sub { print STDERR "$$: HUP Caught\n";
LoadFiles($adfilterfile); print "DONE LOADING\n"; };
sub LoadFiles {
my $adfilterfile = shift;
#load ad filter strings into memory
print "$$: Loading in Ad Filters from $adfilterfile..." if($debug);
open(FILE,"$adfilterfile") || die "Error opening $adfilterfile: $!\n";
@filters = <FILE>;
close(FILE);
for($_=0;$_<@filters;$_++) {
@filters[$_] =~ s/[\r|\n]//g; #Rid of \r \n!
if (@filters[$_] eq '') { pop(@filters); $_--; next; } #skip entry if
it's empty
print ">@filters[$_]\n" if ($debug);
}
print "$$: ", $_ = @filters," Strings Loaded\n" if($debug);
}
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: Wed, 07 Apr 2004 21:47:22 -0400
From: lucas <aolblowz@yahoo.com>
Subject: Re: problem with HangUP
Message-Id: <Pf6dnev-M6u3MundRVn-gw@golden.net>
lucas wrote:
> the sub routine doesn't exit either. i know this because i run it at the
> start of the program. And i know that the $SIG(HUP) shouldn't exit, but
> it
> does. i put a 'print "DONE LOADING\N"; ' in the $SIG, as you can see, and
> it is printed to screen, so the LoadFiles() returns properly.
>
>
> $SIG{HUP} = sub { print STDERR "$$: HUP Caught\n";
> LoadFiles($adfilterfile); print "DONE LOADING\n"; };
>
> sub LoadFiles {
> my $adfilterfile = shift;
>
> #load ad filter strings into memory
> print "$$: Loading in Ad Filters from $adfilterfile..." if($debug);
> open(FILE,"$adfilterfile") || die "Error opening $adfilterfile: $!\n";
> @filters = <FILE>;
> close(FILE);
> for($_=0;$_<@filters;$_++) {
> @filters[$_] =~ s/[\r|\n]//g; #Rid of \r \n!
> if (@filters[$_] eq '') { pop(@filters); $_--; next; } #skip entry
> if
> it's empty
> print ">@filters[$_]\n" if ($debug);
> }
> print "$$: ", $_ = @filters," Strings Loaded\n" if($debug);
> }
I just found that it always has an exit code of "4", if this helps at all
--
lucas
-------------------------
Perl Coder since 2001
shift || die;
-------------------------
------------------------------
Date: 7 Apr 2004 17:13:43 -0700
From: rocknmetal20@yahoo.com (rocknmetal20)
Subject: Question on refs inside hash
Message-Id: <d0b6fd4f.0404071613.3e5e7787@posting.google.com>
Hi all,
Is there a way to refer other elements of the hash inside that hash
WHILE I am defining the hash.
Example: I have a hashref with 'x' mapping to an array ref. To save
memory or for someother reason I want to use that same value for 'y'
too.
For the following,
my $a = {
'x' => ['a'],
'y' => ['a'],
};
Instead duplicating the value for y, I want to refer to value for key
'x'.
I can do
my $a = {
'x' => ['a'],
};
$a->{'y'} = $a->{x};
But I want to know, if it can be done while defining the hash.
This does not seem to work:
my $a = {
'x' => ['a'],
'y' => $VAR1->{x}
};
print Dumper($a);
$VAR1 = {
'x' => [
'a'
],
'y' => undef
};
Thanks
Rock
------------------------------
Date: Thu, 08 Apr 2004 01:58:14 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: Question on refs inside hash
Message-Id: <4074B0E3.5010207@rochester.rr.com>
rocknmetal20 wrote:
...
> Is there a way to refer other elements of the hash inside that hash
> WHILE I am defining the hash.
>
> Example: I have a hashref with 'x' mapping to an array ref. To save
> memory or for someother reason I want to use that same value for 'y'
> too.
>
> For the following,
> my $a = {
> 'x' => ['a'],
> 'y' => ['a'],
> };
> Instead duplicating the value for y, I want to refer to value for key
> 'x'.
> I can do
> my $a = {
> 'x' => ['a'],
> };
>
> $a->{'y'} = $a->{x};
>
> But I want to know, if it can be done while defining the hash.
Try:
my $arrayref=['a'];
my $a={x=>$arrayref,y=>$arrayref,};
Note carefully that $a->{x} and $a->{y} then refer to *exactly the same
array*, and that a statement like:
$a->{x}->[0]='b';
will result in:
print $a->{y}->[0];
printing "b".
>
> This does not seem to work:
> my $a = {
> 'x' => ['a'],
> 'y' => $VAR1->{x}
???--------------^^^^
Where was $VAR1 defined? And, if you had used $a instead of $VAR1, it
wouldn't have worked either, because the order of evaluation calls for
the anonymous hash reference to be built first, then assigned to $a, so
$a wouldn't exist during the time the anonymous hash is being built.
> };
>
> print Dumper($a);
>
> $VAR1 = {
> 'x' => [
> 'a'
> ],
> 'y' => undef
> };
>
...
> Rock
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 07 Apr 2004 22:40:19 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: scope again
Message-Id: <4074828C.3070205@rochester.rr.com>
Richard Morse wrote:
> In article <406EE9A5.6010803@rochester.rr.com>,
> Bob Walton <invalid-email@rochester.rr.com> wrote:
>
>>Bob Walton wrote:
>>
>>>Richard Morse wrote:
>>>
>>>>Wait -- completely un-related to the question, what is this? How do
>>>>you get an interactive Perl?
>>>>
>>>Windoze version:
>>>
>>> perl -e "print '% ',eval <STDIN>,print qq(\n) while 1"
>>>
>>Well, actually:
>>
>> perl -e "print('% '),eval <STDIN>,print qq(\n) while 1"
>>
>>works better.
>>
>
> Cool! Is there a better version for Mac OS X?
>
> Thanks,
> Ricky
>
>
I don't know much^Wanything about OS X, but in general for non-Windoze:
perl -e 'print("% "),eval <STDIN>,print "\n" while 1'
should work [untested].
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Wed, 07 Apr 2004 18:52:49 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: scoping, sig handlers, and labels
Message-Id: <09ednQa1ZaMeP-ndRVn-iQ@adelphia.com>
ctcgag@hotmail.com wrote:
> Bill <wherrera@lynxview.com> wrote:
>
>>ctcgag@hotmail.com wrote:
>>
>>>I expect the program below to go into an infinite loop after print 9,
>>>
>>>#perl -w
>>>use strict;
>>>REDO:foreach(1..1000) {
>>> $SIG{ALRM}=sub {redo REDO};
>>> alarm 10;
>>> system "sleep $_"; # don't use builtin sleep, just in case.
>>> alarm 0;
>>> print "$_\n";
>>>};
>>
>>from perlfunc:
>>===
>>It is usually a mistake to intermix alarm and sleep calls. (sleep may be
>>internally implemented in your system with alarm)
>
>
> That's why I shelled out to do the sleep, not that it makes any difference.
>
> Xho
>
I see what you mean, having run the code on linux now. And look at this:
#!/usr/bin/perl
use strict;
use warnings;
my $rdo = sub { goto REDO; };
REDO:
foreach(1...1000) {
print "$_ ... ";
$SIG{ALRM}= $rdo->();
alarm 10;
system "sleep $_"; # don't use builtin sleep, just in case.
alarm 0;
print "$_\n";
}
This one loops forever, but I don't see why it does, and why your
example cannot see the REDO scope. Maybe closures are buggy here?
------------------------------
Date: Wed, 07 Apr 2004 22:05:08 GMT
From: C. Smith <cs31504@hotmail.com>
Subject: Shell-escaping from perl
Message-Id: <oW_cc.10669$bd4.1401@nwrddc01.gnilink.net>
Suppose I want to invoke a shell command from perl and provide some user-supplied data as input to the shell command. The user-supplied input has to be escaped so the shell will not interpret any part of it. I already know how to write a regular expression to do this - this regular expression is littered throughout my code in far too many places. What I want to know is if there is a function in a standard perl module somewhere that will do this. Every time I copy and paste my homegrown regular expression, I worry I'm missing part of it, and it's not terribly readable. (I do not want to take my regular expression and make my own function out of it - this does not solve the problem for when I start a batch of new code because I'd have to cart that function around with me.)
------------------------------
Date: 7 Apr 2004 22:31:47 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Shell-escaping from perl
Message-Id: <slrnc790al.r1m.xx087@smeagol.ncf.ca>
C Smith <cs31504@hotmail.com> wrote:
>
> Suppose I want to invoke a shell command from perl and provide some
> user-supplied data as input to the shell command. The user-supplied
> input has to be escaped so the shell will not interpret any part of
> it. I already know how to write a regular expression to do this -
> this regular expression is littered throughout my code in far too
> many places. What I want to know is if there is a function in a
> standard perl module somewhere that will do this. Every time I copy
> and paste my homegrown regular expression, I worry I'm missing part
> of it, and it's not terribly readable. (I do not want to take my
> regular expression and make my own function out of it - this does not
> solve the problem for when I start a batch of new code because I'd
> have to cart that function around with me.)
quotemeta is probably what you want:
my $cmd = q{foo bar `nasty command`}
`echo $cmd`
my $safe = quotemeta $cmd
`echo $safe`
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Wed, 07 Apr 2004 16:05:25 -0700
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Shell-escaping from perl
Message-Id: <rcgbrm3wfre.fsf@Jon-Ericson.sdsio.prv>
C. Smith <cs31504@hotmail.com> writes:
> Suppose I want to invoke a shell command from perl and provide some
> user-supplied data as input to the shell command. The user-supplied
> input has to be escaped so the shell will not interpret any part of
> it.
You might consider using taint mode (-T). See the perlsec manpage.
> I already know how to write a regular expression to do this - this
> regular expression is littered throughout my code in far too many
> places. What I want to know is if there is a function in a standard
> perl module somewhere that will do this. Every time I copy and
> paste my homegrown regular expression, I worry I'm missing part of
> it, and it's not terribly readable.
Have you searched CPAN? I found something promising at
<http://search.cpan.org/src/ROSCH/String-ShellQuote-1.00/>.
> (I do not want to take my regular expression and make my own
> function out of it - this does not solve the problem for when I
> start a batch of new code because I'd have to cart that function
> around with me.)
Turn it into a module. Even better, submit it to CPAN. :-)
Jon
------------------------------
Date: 7 Apr 2004 19:17:32 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Why does split operate over multiple lines in the absence of "ms" ? And why doesn't $_ work with split?
Message-Id: <776e0325.0404071817.6fe7aae4@posting.google.com>
"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> wrote in message news:<c51o1l$il5$1@nets3.rz.RWTH-Aachen.DE>...
> Also sprach Sara:
>
> > To substitute over multiple lines, one would need something like
> >
> > s/CAT/DOG/msg;
>
> No, one wouldn't. The only thing you need is /g, and that doesn't have
> anything to do with strings spanning multiple lines. The /s modifier is
> only meaningful when you have a '.' which otherwise doesn't match
> newlines. /m changes the meaning of '^' and '$'.
>
> > But to SPLIT those same lines the "ms" is apparently "implied":
> >
> > my @all_matches = split /CAT/, $_;
> > my @all_matches = split /CAT/ms, $_;
>
> Same here. These two lines do the same thing because
>
> /CAT/
> /CAT/ms
>
> are equivalent.
>
> > will both split the entire paragraph, not just line 1. Why? Why would
> > one assume that programmers would need to substitute only line 1, but
> > wold always need to split the whole paragraph.
>
> Note that split() has an additional third argument. If you want to split
> only once, then pass 2 as third argument.
>
> So the only thing that split() implies is /g and that I find rather
> plausible.
>
> Tassilo
Hmm curiously, you're correct. I seem to have /ms all over my code now
for no good reason. Major misconception on my part, thanks for
clearing it up.
G
------------------------------
Date: Thu, 08 Apr 2004 02:30:28 +0200
From: Frank de Bot <ppi_doesnt_like_@spam_inhis_email_searchy.net>
Subject: wrong exitstatus returned?
Message-Id: <c526fo$bk4$1@news2.tilbu1.nb.home.nl>
Hi,
I have a perl script server which works with fork. But I got a problem
with executing commands from a child which handles a request. The
exitstatus $? is always -1 I've tried execute commands with system and
`command` but nothing matters.
What can be wrong?
Thanks in advanced,
Frank de bot
------------------------------
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 6374
***************************************