[23486] in Perl-Users-Digest
Perl-Users Digest, Issue: 5699 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 23 00:05:52 2003
Date: Wed, 22 Oct 2003 21:05:08 -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, 22 Oct 2003 Volume: 10 Number: 5699
Today's topics:
Re: c programmer in need of perl advise (Tad McClellan)
Re: c programmer in need of perl advise chance@austin.rr.com
Re: C vs Perl <kst@cts.com>
Re: file redirect within back ticks not working <ddunham@redwood.taos.com>
Re: Installing DBD::Sybase on MAC <mpeppler@peppler.org>
Re: IO::Socket::INET - Listen on exactly two IPs the sa (Kai Bleek)
newbie perl - html question <bbxrider1@comcast.net>
Re: newbie perl - html question <tom@ztml.com>
Re: Oddity with the x and . operators (Tad McClellan)
Re: Pattern match over mutiple files is slow - Help Nee (RV)
Re: Perl and IIS - script runs but 'The page cannot be (stew dean)
Re: Perl and IIS - script runs but 'The page cannot be <flavell@ph.gla.ac.uk>
Re: Perl and IIS - script runs but 'The page cannot be <jurgenex@hotmail.com>
Re: Perl and IIS - script runs but 'The page cannot be (James Willmore)
Re: Regex to extract row data from text (Copy of data i (Tad McClellan)
Re: Simulating case sensitivity for win32 files (Malcolm Dew-Jones)
Re: Simulating case sensitivity for win32 files <kalinaubears@iinet.net.au>
Re: Taint - having some real trouble here, taint/perl e <grazz@pobox.com>
Re: Taint - having some real trouble here, taint/perl e (Tad McClellan)
Re: while each hash, why not array (Tad McClellan)
Re: while each hash, why not array <asu1@c-o-r-n-e-l-l.edu>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Oct 2003 16:18:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: c programmer in need of perl advise
Message-Id: <slrnbpdt1h.5h1.tadmc@magna.augustmail.com>
chance@austin.rr.com <chance@austin.rr.com> wrote:
> Mike Deskevich <mikedeskevich@yahoo.com> wrote:
>> my main question is: is
>> there a faster way to read the data than how i'm currently doing it
>> here's how i read my data files
>
>> $ct=0;
>> while (<DATAFILE>)
>> {
>> ($xvalue[$ct],$yvalue[$ct])=split;
>> $ct++;
>> }
>> i
>> think that most of the time is being used in either perl start up
^^^^^
>> time, or data reading time, the post processing is happening pretty
>> fast (i think)
Profile it and then you'll *know* where the slow part is.
> If you knew in advance the length you could do :
>
> $xvalue[$vector_len - 1] = 0.0
But what if 0.0 is a legal value?
How will you know that this is the bogus one?
$#xvalue = $vector_len - 1; # extend @xvalue array with undef values
> if the lengths of your vectors really are unknowable, then you could
> at least start pre-allocating chunks in advance and doubling the
> size each time you 'run out of room',
Which is roughly what perl is doing for you already...
> A real guru may have a much better answer
It seems unlikely to me that it is I/O bound.
The only way to know is to profile it, until then we're
spinning our wheels.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 23 Oct 2003 04:03:26 GMT
From: chance@austin.rr.com
Subject: Re: c programmer in need of perl advise
Message-Id: <bn7k1k$frh$1@localhost.localdomain>
>> If you knew in advance the length you could do :
>>
>> $xvalue[$vector_len - 1] = 0.0
> But what if 0.0 is a legal value?
> How will you know that this is the bogus one?
well ..... was planning on writing over the 0.0 with valid data.
All irrelevant if perl does the allocation in a manner which
garuantees log(N) allocs though. so there went that guess.
>> if the lengths of your vectors really are unknowable, then you could
>> at least start pre-allocating chunks in advance and doubling the
>> size each time you 'run out of room',
> The only way to know is to profile it, until then we're
> spinning our wheels.
agreed. was just shooting from the hip.
Mr. Orginal poster: if you do actually profile, I would
be interested to know where the first bottleneck is.
my money is now on finding a sscanf-ish replacement for the
split statement. But thats just because I haven't thought of
anything else.
--
I used to think government was a necessary evil.
I'm not so sure about the necessary part anymore.
------------------------------
Date: Thu, 23 Oct 2003 01:50:04 GMT
From: Keith Thompson <kst@cts.com>
Subject: Re: C vs Perl
Message-Id: <lzekx4solq.fsf@cts.com>
Noah Roberts <nroberts@dontemailme.com> writes:
> len v wrote:
>
> > Note to self. Find spell checker for vi.
> > Looks like I spelled it wrong on the web site too. 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.
> >
>
> My compiler really doesn't like it when I spell freind wrong.
Mine doesn't care.
--
Keith Thompson (The_Other_Keith) kst@cts.com <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://www.sdsc.edu/~kst>
Schroedinger does Shakespeare: "To be *and* not to be"
------------------------------
Date: Wed, 22 Oct 2003 22:05:36 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: file redirect within back ticks not working
Message-Id: <QaDlb.3497$oC.52937829@newssvr21.news.prodigy.com>
ktom <abc@nowhere.com> wrote:
> from with a perl script this line does not work
> `sed -e 1,14d $file >> /tmp/junk`;
> it seems the redirect does not work.
Does for me..
Did you set $file properly?
Why are you using backticks when you don't expect output from sed? You
might want to use system() instead (although that's not your problem).
What OS are you using?
$ perl -le 'foreach (1 .. 16) { print "Line $_"; }' > /tmp/input
$ perl -e '$file = "/tmp/input"; `sed -e 1,14d $file >> /tmp/junk`'
$ cat /tmp/junk
Line 15
Line 16
$
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Wed, 22 Oct 2003 16:32:19 -0700
From: "Michael Peppler" <mpeppler@peppler.org>
Subject: Re: Installing DBD::Sybase on MAC
Message-Id: <pan.2003.10.22.23.32.18.265420@peppler.org>
On Tue, 21 Oct 2003 22:10:05 -0700, Vijoy Varghese wrote:
> "Michael Peppler" <mpeppler@peppler.org> wrote in message
>
>> First, Sybase's OpenClient package doesn't work with MS-SQL 7.x or 2K.
>> Second, how could the *linux* version of OpenClient ever work on your
>> MacOSX box??? The underlying architecture is completely different!
>
> What about installing 'Free BSD Intel' from
> http://linux.sybase.com/ase/11033download.html.
> Will this work on a Mac osX and DBD::Sybase?
> If it does, should I install both files to get it work with
> DBD::Sybase?
>
> sybase-ocsd-10.0.4-FreeBSD-6.i386.tgz AND
> sybase-ase-11.0.3.3-FreeBSD-6.i386.tgz
No - this FreeBSD on intel - it won't work on your PPC Mac!
Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler@peppler.org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html
------------------------------
Date: 22 Oct 2003 15:08:32 -0700
From: public@spellweaver.de (Kai Bleek)
Subject: Re: IO::Socket::INET - Listen on exactly two IPs the same time?
Message-Id: <4b1ad64e.0310221408.1629ab9b@posting.google.com>
Hi again,
> 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.
well - guess you're right about that - some artefact from my figuring
out how to use IO::Select.
> 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.
I couldn't quite get along with the dipatch tables. Since I want to
fork any connect as soon as it hits the server, my loop now looks like
this:
while (1) {
my @select_set = $read_set->can_read;
foreach my $server (@select_set) {
fork_connect($server);
}
}
Quite clearly arranged, isn't it? In the forking code I built
something one would use a "case"-contruct for if it were not perl
we're using:
if ($childpid == 0) {
if ("$server_ip" eq "$ini_ref->{'section'}->{'LOCAL_ADDRESS'}") {
remote_connect($connect);
} elsif ("$server_ip" eq "127.0.0.1") {
local_connect($connect);
} else {
die "Connect from undef IP!\n";
}
}
Not the most elegant way I guess, but it works for now.
Thanks again for the help! I keep that dispatch table alternative in
mind for later improvements.
Kai
------------------------------
Date: Thu, 23 Oct 2003 02:10:01 GMT
From: "bbxrider" <bbxrider1@comcast.net>
Subject: newbie perl - html question
Message-Id: <ZLGlb.1009$9E1.7747@attbi_s52>
am trying to output the first part of a web page, see
www.job1data.com/phsheader.htm
i've tried putting the exact html code for the above in my perl file like
this
print "Content-type:text/html\n\n";
print <<EndHdr;
html code here, (not enclosed in quotes)
EndHdr
the page kinda starts to come up but the graphics are x'd out and it seems
to basically grind to a halt
perl is basically working on the site see, www.job1data.com/perl1.plx
i haven't seen anywhere where for some reason the html code is 'limited'
when being generated from a perl script but obviously am running into some
problem here
------------------------------
Date: Thu, 23 Oct 2003 03:19:44 GMT
From: tom <tom@ztml.com>
Subject: Re: newbie perl - html question
Message-Id: <kNHlb.15461$Vf7.14599@nwrdny02.gnilink.net>
bbxrider (comcast.net) wrote:
>am trying to output the first part of a web page, see
>www.job1data.com/phsheader.htm
>i've tried putting the exact html code for the above in my perl file like
>this
>
>print "Content-type:text/html\n\n";
>print <<EndHdr;
>
>html code here, (not enclosed in quotes)
>
>EndHdr
>
>the page kinda starts to come up but the graphics are x'd out and it seems
Your perl script and images files might not in the same directory. In this
case, you need to specify the location of your image files with an absolute
path. For example: <img src="http://job1data.com/images/phslogo.bmp"
>to basically grind to a halt
>perl is basically working on the site see, www.job1data.com/perl1.plx
>i haven't seen anywhere where for some reason the html code is 'limited'
>when being generated from a perl script but obviously am running into some
>problem here
>
------------------------------
Date: Wed, 22 Oct 2003 17:11:06 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Oddity with the x and . operators
Message-Id: <slrnbpe03q.5h1.tadmc@magna.augustmail.com>
Dan Wilga <dwilga-MUNGE@mtholyoke.edu> wrote:
> I've run into something that has me totally puzzled.
That can happen when you do not enable warnings.
(so you should enable them)
> However, if I do:
>
> print ("." x 5)."foo";
>
> I get only:
>
> .....
You should always enable warnings when developing Perl code.
> Why does the "foo" get discarded?
It isn't (directly) discarded.
It is concatentated with whatever print() returned (probably a 1)
and the result of the concatenation is then discarded (void context).
> I can get around this by changing the code to:
>
> print scalar("." x 5)."foo"
Or to any of these:
print( ("." x 5) . "foo"); # parens around _entire_ arg list
print "." x 5 . "foo";
print +("." x 5) . "foo";
> But, according to perlop, I wouldn't think this should be necessary:
>
> "In scalar context or if the left operand is not enclosed in
> parentheses, it returns a string consisting of the left operand repeated
> the number of times specified by the right operand."
The problem is not related to concatenation, the problem is
related to print() (or _any_ function actually).
> Shouldn't the use of the '.' operator outside be sufficient to cause the
> parenthetical part to be considered a scalar?
Yes, but not-being-a-scalar is not your problem.
> Even if it's not, and the
> bit inside the parens evaluates to a single-element list, I would still
> expect to see:
>
> 1foo
Why would you expect that?
(a list in scalar context does NOT evaluate to the number of
elements in the list. In fact, a list cannot exist in scalar
context at all!)
See this thread for what is really causing your problem (wrapped):
http://groups.google.com/groups?
as_umsgid=slrnatq036.2q2.tadmc%40magna.augustmail.com
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Oct 2003 18:19:42 -0700
From: rvstore1@yahoo.com (RV)
Subject: Re: Pattern match over mutiple files is slow - Help Needed !
Message-Id: <35c0f847.0310221719.5447025b@posting.google.com>
Darren Dunham <ddunham@redwood.taos.com> wrote in message news:<WmClb.3253$ku5.2713@newssvr25.news.prodigy.com>...
> RV <rvstore1@yahoo.com> wrote:
> > #Note: %keyval --> holds the key-value mapping
> > # @keylist - is the array with the 1000 keys ( like keys %keyval )
> > # @files - holds the list of files ( about 100 or so ).
>
> How big are the files?
It varies - I would say the average is about 150 Kbytes - usually not
more than 250 Kbytes.
>
>
> If the files are small enough to hold in memory, then run the
> substitution on the entire file rather than line by line.
>
> undef $/;
> my $info =<FILE>;
> foreach $k (@keylist)
> {
> $info =~ s/$k/$keyval{$k}/img ; #replace key with value
> } #key loop
>
> That might be a big improvement already.
>
I did try slurping the complete file - did not seem to make it any
faster.
It takes about 10 mins on large ( 120 Kbytes ) file for that loop :(
>
>
> Another question. How often do the patterns actually occur in the file?
> If they're pretty rare (many lines that don't require any
> substitutions), then you could do the original "match by line", but do a
> check on *all* the patterns for each line (fast) before attempting the
> substitutions (slower).
>
> # compile regex with all keys in it.
> my $re_str = join "|", @keylist;
>
> # file loop
> while (<FILE>)
> {
> if (/$re_str/)
> { # substitute loop }
> }
Yes - I expect to have patterns sparsely ( relatively speaking, of
course ! ).
Interesting - I will try your idea.
BTW, Is there a limit on the size of the pattern joined by "|" ? -- As
i said I expect about 1000 entries in the keylist. ( well other than
physical memory limits :) ). ????
FWIW, its now running on a SPARC Solaris 9 machine with about 1024 RAM
- Single US-2 CPU.
Thanks for the suggestions - I will try it and post back here .....
------------------------------
Date: 22 Oct 2003 15:10:58 -0700
From: stewart@webslave.dircon.co.uk (stew dean)
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <2b68957a.0310221410.141f9d3f@posting.google.com>
James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031022114233.1492c7aa.jwillmore@remove.adelphia.net>...
> On 22 Oct 2003 04:27:54 -0700
> stewart@webslave.dircon.co.uk (stew dean) wrote:
> > James Willmore <jwillmore@remove.adelphia.net> wrote in message
> > news:<20031021114710.504263f7.jwillmore@remove.adelphia.net>...
> > > On 21 Oct 2003 03:53:24 -0700
> > > stewart@webslave.dircon.co.uk (stew dean) wrote:
> <snip>
>
> What happened when you ran the script at the command line?
I've never run a perl script at the command line.
> There is
> _little_ difference between running the script on the command line and
> running it through the web server - especially if you use the CGI
> module (hint - '-debug').
> Where is the code you speak of? You have yet to post any offending
> code.
There is no offending code. I'm not posting up my script as the script
works fine. It takes an XML file and spits out other files (html) and
one HTML page which tells me the script has run and gives me more
options (like adding details to selected pages).
> The documentation for _Perl_ (specifically, perlfaq9) gives a tip or
> two on debugging a buggy Perl CGI script.
The perl script is not buggy - it's running fine. It generates all the
files but for some reason is not producing my final HTML page.
> And yes, I was insulting to you. Sorry for the transgression. By the
> same token, if you run a web server, you should at least know where
> the logs are located
Which logs? I use the events log, I run stats on the access logs. Now
what I don't appear to be able to find is the perl error log if there
is one.
> For the time being - and to give a hint - try using CGI::Carp (just
> not in a production environment).
Well that's enigmatic. I suspect that it's also not the answer I seek
but I will check it out.
Stew Dean
------------------------------
Date: Thu, 23 Oct 2003 00:31:40 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <Pine.LNX.4.53.0310230029460.11611@ppepc56.ph.gla.ac.uk>
On Wed, 22 Oct 2003, stew dean acidicly remarked for the benefit of
the gallery:
> Thanks for what is probably the only helpful responce so far.
I think that's reached the plonk threshold now. Bye.
------------------------------
Date: Thu, 23 Oct 2003 00:31:14 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <mjFlb.28443$Ee6.26897@nwrddc01.gnilink.net>
stew dean wrote:
> The perl script is not buggy - it's running fine.
Then what is your problem? Apparently it has nothing to do with Perl or has
it?
jue
------------------------------
Date: 22 Oct 2003 18:26:59 -0700
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <d61170e5.0310221726.7b4f6315@posting.google.com>
stewart@webslave.dircon.co.uk (stew dean) wrote in message news:<2b68957a.0310221410.141f9d3f@posting.google.com>...
> James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031022114233.1492c7aa.jwillmore@remove.adelphia.net>...
> > On 22 Oct 2003 04:27:54 -0700
> > stewart@webslave.dircon.co.uk (stew dean) wrote:
> > > James Willmore <jwillmore@remove.adelphia.net> wrote in message
> > > news:<20031021114710.504263f7.jwillmore@remove.adelphia.net>...
> > > > On 21 Oct 2003 03:53:24 -0700
> > > > stewart@webslave.dircon.co.uk (stew dean) wrote:
> > <snip>
> >
> > What happened when you ran the script at the command line?
>
> I've never run a perl script at the command line.
Why not?
>
> > There is
> > _little_ difference between running the script on the command line and
> > running it through the web server - especially if you use the CGI
> > module (hint - '-debug').
>
> > Where is the code you speak of? You have yet to post any offending
> > code.
>
> There is no offending code. I'm not posting up my script as the script
> works fine. It takes an XML file and spits out other files (html) and
> one HTML page which tells me the script has run and gives me more
> options (like adding details to selected pages).
>
> > The documentation for _Perl_ (specifically, perlfaq9) gives a tip or
> > two on debugging a buggy Perl CGI script.
>
> The perl script is not buggy - it's running fine. It generates all the
> files but for some reason is not producing my final HTML page.
Hum ... are you outputing the correct HTTP header? Maybe there _is_
something wrong with the script? A typo, maybe? Running the script
_at the command line_ will produce messages that _may_ not be seen as
errors, but as warnings that the web server is just dismissing. You
can also see what the script is sending out to the browser. What ever
you see at the command line is what _should_ be going to the browser.
>
> > And yes, I was insulting to you. Sorry for the transgression. By the
> > same token, if you run a web server, you should at least know where
> > the logs are located
>
> Which logs? I use the events log, I run stats on the access logs. Now
> what I don't appear to be able to find is the perl error log if there
> is one.
There are _no_ Perl error logs. The error logs I was refering to were
the _server_ error logs. However, you can issue events to the
Window's Event Log from the script using the Win32::EventLog module.
By inserting some logging code into your script, you can see each time
the code to produce HTML is hit. You can then see what, if anything,
broke.
>
> > For the time being - and to give a hint - try using CGI::Carp (just
> > not in a production environment).
>
> Well that's enigmatic. I suspect that it's also not the answer I seek
> but I will check it out.
Like I mentioned before, maybe the code _is_ broke somewhere.
CGI::Carp can report the errors to the browser (since you seem to not
want to run the script at the command line). If something is broke,
the error will appear.
HTH
Jim
(jwillmore _at_ adelphia _dot_ net)
------------------------------
Date: Wed, 22 Oct 2003 16:20:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex to extract row data from text (Copy of data included)
Message-Id: <slrnbpdt4b.5h1.tadmc@magna.augustmail.com>
Glenn Jackman <xx087@freenet.carleton.ca> wrote:
> Looks like fixed width fields, as opposed to delimited.
> If so, use substr() to extract the data.
unpack() is the Right Tool for fixed width fields.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 22 Oct 2003 16:10:59 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Simulating case sensitivity for win32 files
Message-Id: <3f970e83@news.victoria.tc.ca>
M&M (mm-24@pobox.com) wrote:
: I understand that windows filesystems are case insensitive though case
: preserving. My dilema is that files on my windows server are synced
: to a linux web server where case sensitivity does matter.
: Is there a way to simulate "-f test.txt" in a case sensitive manner or
: perhaps retrieve a file's actual name? I was surprised to learn that
This sort of information is available in windows, so I would assume that
the various win32 module(s) would have some way to get the information.
------------------------------
Date: Thu, 23 Oct 2003 10:22:47 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Simulating case sensitivity for win32 files
Message-Id: <3f972010$0$23601$5a62ac22@freenews.iinet.net.au>
M&M wrote:
>
> #!/usr/bin/perl -w
>
> chdir "c:/temp";
>
> my $file = "test.txt";
>
> if (-f $file and not really_exists($file)) {
> my $realname = real_filename($file);
> warn "Renaming $realname to $file.\n";
> rename $realname, $file or die "Can't rename $realname: \n";
> }
>
> sub really_exists {
> my $filename = shift;
> return $filename eq real_filename($filename) ? 1 : 0;
> }
>
> sub real_filename {
> my $filename = shift;
> opendir DIR, "." or die "Can't readdir: $!";
> (my $realname) = grep { $filename =~ /^${_}$/i } readdir DIR;
> closedir DIR;
> return $realname;
> }
I think one improvement would be to create an array containing the
actual names of the files so that you aren't constantly re-reading
through the directory.
@real_filenames = grep { -f "$_"} readdir DIR;
# assumes the opened dir is "."
# In general: grep {-f "$dir/$_"} readdir DIR;
really_exists() could then look something like this:
sub really_exists {
my $filename = shift;
for(@real_filenames) {
if($_ eq $filename) {return 1}
if(lc($_) eq lc($filename)) {return 2}
}
return 0;
}
Hth.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Wed, 22 Oct 2003 22:15:44 GMT
From: Steve Grazzini <grazz@pobox.com>
Subject: Re: Taint - having some real trouble here, taint/perl experts, please help
Message-Id: <kkDlb.14792$Vf7.4003@nwrdny02.gnilink.net>
Ben <2stormts@nemontel.net> wrote:
> Darren Dunham <ddunham@redwood.taos.com> wrote:
>> What leads you to think that it "acts like it is tainted"?
>
> The behaviour - if I use ("literalCMD",$param,$param,etc) form of
> system(), it works. If I use the ("$aggregateCMD $param $param etc.")
> form, it doesn't.
It's true that "system LIST" is exempt from taint-checking,
but if this were actually a taint problem, you'd get an error
of the form
Insecure dependency in foo ...
Insecure $ENV{FOO} ...
>> What error messages are you getting?
>
> No error messages. system() returns 0 and !$ is empty.
Taint-checking doesn't cause things to silently fail!
Look, if you don't know what's going wrong, please just show us a
small-but-complete script that demonstrates the behavior.
If it fails from cron/CGI/etc and you haven't even tried it from
the command-line, you should go try it from the command-line first.
>>> exec("/usr/src/client/client",$p1,$p2,$p3,$p4);
>>> exit;
>>
>> That exit line is never executed. The perdoc on exec will tell you
>> why. If you want to do that, use a fork as above.
>
> I was concerned about the exec() call failing, as things weren't
> working right. Since if exec() fails, it does return, I think it's
> important to leave that in there. Correct me if I'm wrong, please.
Well you're right that exec() can fail, but just exit() isn't
very useful either.
exec $whatever;
die "couldn't exec $whatever: $!";
--
Steve
------------------------------
Date: Wed, 22 Oct 2003 16:39:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Taint - having some real trouble here, taint/perl experts, please help
Message-Id: <slrnbpdu84.5h1.tadmc@magna.augustmail.com>
Ben <2stormts@nemontel.net> wrote:
> which is laundered
> thusly:
>
> $part = partlaundry($in{'partnumber'});
> ...
> exit;
>
> sub legalpchar
> {
> my $char = shift;
> my $val = ord($char);
>
> if ($char eq "*") { return(1); }
> if ($val >= ord("A") && $val <= ord("Z")) { return(1); }
> if ($val >= ord("a") && $val <= ord("z")) { return(1); }
> if ($val >= ord("0") && $val <= ord("9")) { return(1); }
> return(0); # forget it.
> }
>
> sub partlaundry
> {
> my $text = shift;
> my $len = length($text);
> my $rez = "";
> my $i;
> my $char;
>
> for ($i=0; $i<$len; $i++)
> {
> $char = substr($text,$i,1);
> if (legalpchar($char) == 1)
> {
> $rez .= $char;
> }
> }
> return($rez);
> }
There is no pattern match in that code, so nothing can possibly
become untainted.
When you copy tainted data, the copy is tainted too.
And that seems like a whole lot of code.
Can't it all be replaced with just:
# untested
sub partlaundry {
my $text = shift;
return '' unless $text =~ /^([a-zA-Z0-9*]*)$/;
return $1;
}
??
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 22 Oct 2003 17:16:21 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: while each hash, why not array
Message-Id: <slrnbpe0dl.5h1.tadmc@magna.augustmail.com>
A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:
> for(my $i = 0; $i != @arr; ++$i) {
Yuck!
foreach my $i ( 0 .. $#arr ) {
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 23 Oct 2003 03:55:24 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: while each hash, why not array
Message-Id: <Xns941CF35CF96DDasu1cornelledu@132.236.56.8>
tadmc@augustmail.com (Tad McClellan) wrote in
news:slrnbpe0dl.5h1.tadmc@magna.augustmail.com:
> A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:
>
>> for(my $i = 0; $i != @arr; ++$i) {
>
>
> Yuck!
>
> foreach my $i ( 0 .. $#arr ) {
Agreed. Thanks.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
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 5699
***************************************