This is really dangerous.... don't do this. Don't use $1 unless you've also
checked that the match has succeeded. If you're *absolutely* sure it will
*always* match, at least add "or die" so that your program will abort *when*
you are wrong (not "if" .
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
< merlyn%40stonehenge.com">merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
> Glenn> /:s+(.*tgz$)/;
> Glenn> push packages, $1;
>
> This is really dangerous.... don't do this. Don't use $1 unless
> you've also checked that the match has succeeded. If you're
> *absolutely* sure it will *always* match, at least add "or die" so
> that your program will abort *when* you are wrong (not "if" .
Aww, I shoulda known it was just too easy! I ain't THAT smart! :^T
Thanks again, Randal. Back to the proverbial drawing board ... er, xterm.
> Glenn> /:s+(.*tgz$)/;
> Glenn> push packages, $1;
>
> This is really dangerous.... don't do this. Don't use $1 unless
> you've also checked that the match has succeeded.
Would this be a reasonable place to use "eval" -- say, wrap the two
lines above in an "eval" block? like the following
eval { /:s+(.*tgz$)/;
push packages, $1 };
print "No match occurred!n:$" if $;
Is the danger of using $1 that, if the match does not succeed, you are
accessing a "left-over" $1 from another match?