![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Opening a filehandle but not getting anything back from it | Smiling Dragon | Shell Programming and Scripting | 8 | 08-16-2008 03:40 AM |
| ls command to print fifo of contents (or perl) | jerardfjay | Shell Programming and Scripting | 1 | 04-06-2006 03:01 PM |
| Opening files | saarshad001 | UNIX for Dummies Questions & Answers | 3 | 11-28-2003 12:42 PM |
| Opening Files | AJA | UNIX for Dummies Questions & Answers | 4 | 11-10-2003 11:25 AM |
| Opening Perl | perleo | Shell Programming and Scripting | 2 | 08-26-2002 10:41 AM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Opening Files and checking contents in Perl
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 ";
Expected Output: false1_sorts false_sorts true1_sorts true_sorts true1_sorts true_sorts Last edited by Raynon; 08-31-2008 at 07:39 AM.. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|