> I define two arrays - one is an active changing file ( @unix = ps -ef ) and > need to compare it to a static text file @static = `cat myfile`. > > Would someone help me on the syntax of greping for @static matches in the > @unix array.
<snip> > I am not sure if I need to assign a variable, for loop etc with in the { } > to get the pattern matching results I need. I nested two foreach loops: [localhost:~/Programming/Perl/Various code] tor% cat matching.pl #!/usr/bin/perl -w use strict; my @array1 = qw(file1 file2 file3 file4 file5); my @array2 = qw(file1 file2 file4 file5); my @result; foreach my $file (@array1) { foreach my $file2 (@array2) { if ($file eq $file2) { push(@result, $file); } } } print "@result\n"; [localhost:~/Programming/Perl/Various code] tor% ./matching.pl file1 file2 file4 file5 Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]