Perl/Shell/Python Knowledge Sharing
Perl, shell, python Interview Questions and Answers and quiz
Saturday, January 15, 2011
perl: grep array against array
my @characteristic = ("LA","SF");
my @info_tony = ("LA","SF","NY");
my %seen = ();
my @union = grep { $seen{ $_ }++ } @characteristic, @info_tony;
if ( @union ) {
print "$_\n" for @union;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment