Todd W wrote:
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
This is an equivalent program:
#!/usr/bin/perl print "@ARGV\n"; print "$_\n" for grep length($_) <= 3, @ARGV;
Ha Ha even better, nice one Bob!
Perl is just way to awesome :)
You can even get rid of the for:
print map "\t$_\n", @ARGV; print map "$_\n", grep length() <= 3, @ARGV;
Interesting, here's a couple benchmarks for for() vs. map():
for - print "$_\n" for grep length($_) <= 3, @ARGV map - map "$_\n", grep length() <= 3, @ARGV
Benchmark: timing 1000000 iterations of for, map...
for: 0.338836 wallclock secs ( 0.32 usr + 0.01 sys = 0.33 CPU) @ 3030303.03/s (n=1000000)
(warning: too few iterations for a reliable count)
map: 0.491112 wallclock secs ( 0.51 usr + 0.00 sys = 0.51 CPU) @ 1960784.31/s (n=1000000)
Rate map for
map 1960784/s -- -35%
for 3030303/s 55% --
Benchmark: timing 1000000 iterations of for, map...
for: 0.268642 wallclock secs ( 0.45 usr + -0.01 sys = 0.44 CPU) @ 2272727.27/s (n=1000000)
map: 0.663554 wallclock secs ( 0.51 usr + 0.00 sys = 0.51 CPU) @ 1960784.31/s (n=1000000)
Rate map for
map 1960784/s -- -14%
for 2272727/s 16% --
Just FYI :)
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>