Think about Loose Coupling | |
PerlMonks |
using grep to search an arrayby alicatserver (Initiate) |
on May 23, 2011 at 20:05 UTC ( [id://906354]=perlquestion: print w/replies, xml ) | Need Help?? |
alicatserver has asked for the wisdom of the Perl Monks concerning the following question:
I need to search fileB with fileA values. unfortunately, I cant get grep to work. Can anyone help. fileA has 7 char numbers fileB has 7 char plus some text $data_file="FILEA.TXT"; open(DAT, $data_file) || die("Could not open file!"); @raw_data=<DAT>; close(DAT); $fileb="FILEB.TXT"; open(DAT2, $fileb) || die("Could not open file!"); @fileb=<DAT2>; close(DAT2); foreach (@raw_data) { $testit=$_; @grepnames = grep/^$testit/,@fileb; } print "@grepnames\n\n";
Back to
Seekers of Perl Wisdom
|
|