Richard Monson-Haefel wrote:
Hi,
Hello,
I'm writing a paper comparing the use of Perl, Python and Java. My Perl
is pretty bad (as is my Python), so I thought I would check to see if
there is a more efficient way of doing it.
Here is the Perl program
#!/usr/bin/perl -w
@l = @ARGV;
print "@l\n";
@r = ();
foreach $x(@l){
if(length($x) <= 3){
push(@r, $x);
}
}
$y = @r;
print $y;
foreach $y(@r){
print $y."\n";
}
If there is a more efficient, but readable way to write the script
(especially, it would see the first for loop which filters out names
longer than 4 characters) I would really appreciate it.
#!/usr/bin/perl -w
my @r = grep 3 >= length, @ARGV;
print scalar @r, map "$_\n", @r;
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>