in reply to selecting N random lines from a file in one pass

Off-topic, but I can't resist. Every time I see a C-style for loop in someone's Perl code, I die a little inside. How about this instead:

for my $i ( 0 .. $#sample ) { print "[$i] '$sample[$i]'\n"; }

Replies are listed 'Best First'.
Re^2: selecting N random lines from a file in one pass
by seuratt (Novice) on Dec 22, 2004 at 17:49 UTC
    Old habits... =)
    Anyone know if that's actually faster or slower in execution? What about memory consumption?
      Don't worry about it. If there are any differences, they are so small you would never see them outside of a crazy benchmark.
Re^2: selecting N random lines from a file in one pass
by Anonymous Monk on Dec 23, 2004 at 15:10 UTC
    Every time I see someone use $#array just to be able to use foreach to loop over the indices and avoid using a C-style loop, I die a little.