[VPM] bizzare perl code question
Carl B. Constantine
cconstan at csc.UVic.CA
Thu Jan 22 13:45:36 CST 2004
I have some perl code (written by someone else) that seems most ugly and
ineffecient. Here it is:
my ($tmpout,$pgCount);
$tmpout = `/usr/bin/psselect -p1- $dataFile 2>&1 /dev/null | tail -1`;
$tmpout =~ /Wrote [0-9]* pages/;
$pgCount = $&; # find the match from the above line
$pgCount =~ /[0-9]+/; # be sure the number is in the appropriate range
$pgGuess = $&; # match the above
It seems to me, I could replace it with something a little better, like
this:
my ($tmpout, $pgGuess);
$tmpout = `/usr/bin/psselect -p1- $dataFile 2>&1 /dev/null | tail -1`;
($pgGuess) = $tmpout=~ /Wrote (/d+) pages/;
Am I off or would not my code be the same as above?
--
Carl B. Constantine University of Victoria
Programmer Analyst http://www.csc.uvic.ca
UNIX System Administrator Victoria, BC, Canada
cconstan at csc.uvic.ca ELW A248, 721-8766
More information about the Victoria-pm
mailing list