Hi All,
I need some expert help in performing the following in
Perl.
I have a code below but it doesn;t seem to work. Can any expert give me some advice?
Below are the requirements
1) Open numerous files assigned to an array @FILES. Note that the files are always named with the term "sorts". Examples of these file names are "false1_sorts" , "false_sorts" , "true1_sorts" , "true_sorts" etc
2) Search for contents "32N6524" in the opened file. If contents exists, add the file to another array which is @arr_x. Here, the files that this content exist is true1_sorts" , "true_sorts"
Code:
#!/usr/bin/perl
@FILES = ( *sorts );
print "@FILES ";
print "\n";
foreach $summary_x ( @FILES ) {
open(FH, '< $summary_x') or die $!;
while( <FH> ) {
chomp;
if ( /32N6524/ ) {
push (@arr_x, $summary_x)
};
close FH;
};
};
print "@arr_x ";