On Apr 29, 2010, at 9:32 AM, Hein, Nashua NH wrote:
I'm having trouble using time() within the for loop.
The reason I want it within is for usage during: $ perl -ne "do-stuff-
for-each }{ report-result-at-end "
good (12 seconds):
$ perl -e "$x=-time; for (qx(type MYSCRATCH:tmp.tmp)) {$i++; $n++ if /
hein/i; }$x+=time; print qq($i $n $x)"
42979 10 12
bad (0 seconds):
$ perl -e "for (qx(type MYSCRATCH:tmp.tmp)) {$x=-time unless $i++; $n+
+ if /hein/i; }$x+=time; print qq($i $n $x)"
42979 10 0
I think in the second case the loop doesn't actually start until the
whole file has been read in and you do probably process all of it in
less than a second.
________________________________________
Craig A. Berry
mailto:[email protected]
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser