[JOB] Perl Software Developer and Database programmer
Peter Hickman
peter at semantico.com
Thu Feb 23 09:22:22 GMT 2006
Andy Armstrong wrote:
> You step over them...
>
The original code wouldn't have done that.
#!/usr/bin/perl -w
use strict;
use warnings;
my @alphas = qw/1 2 3 4 5 2/;
my @betas = qw/1 2 3 1 2 3/;
my @results;
foreach my $alpha ( @alphas ) {
foreach my $beta ( @betas ) {
if ( $alpha == $beta ) {
push @results, $beta;
}
}
}
print join ( ' ', @results ) . "\n";
Gives: 1 1 2 2 3 3 2 2
I think your code would produce different results.
I'm off to make a cup of tea.
More information about the london.pm
mailing list