scoobyrico has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; my @array1 = (1,2,3); my @array2 = (1,2,3,4,5); my %hash; my %hash2; @hash{@array1} = @array1; @hash2{@array2} = @array2; # get initial length my $len = keys %hash; # remove the unwanted "value" my $old = delete $hash{2}; my $old2 = delete $hash2{2}; # insert a new one foreach my $x (@array2) { next if ($x == $old); $hash{$x} = undef; last if (keys %hash == $len); } @array1 = keys %hash; foreach my $yy (@array1){ print "##".$array1$[yy]."##\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array searching
by GrandFather (Saint) on Apr 12, 2007 at 23:55 UTC | |
|
Re: Array searching
by thezip (Vicar) on Apr 12, 2007 at 23:59 UTC | |
by GrandFather (Saint) on Apr 13, 2007 at 00:14 UTC | |
by thezip (Vicar) on Apr 13, 2007 at 00:41 UTC | |
by scoobyrico (Beadle) on Apr 13, 2007 at 15:07 UTC |