in reply to Re^3: Help with Search String
in thread Help with Search String
Sentences used:use strict; use warnings; my $namesFile = q{names.txt}; open my $namesFH, q{<}, $namesFile or die qq{open: $namesFile: $!\n}; my @names = <$namesFH>; close $namesFH or die qq{close: $namesFile: $!\n}; chomp @names; # Remove line terminators my $namesPatt = join q{|}, @names; my $dataFile = q{data2.txt}; open my $dataFH, q{<}, $dataFile or die qq{open: $dataFile: $!\n}; while ( <$dataFH> ) { print qq{Found name $_\n} if /($namesPatt)/; open FILE, ">>/home/btobin/data3.txt" or die "Unable to Open: $!"; print FILE "$_\n"; <--- somehow this is wrong close FILE; } close $dataFH or die qq{close: $dataFile: $!\n};
This is a data file created to learn how to use Perl . This is how Bob found his way. I wonder what Jonny is going to do. This is a test.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Help with Search String
by johngg (Canon) on Dec 07, 2007 at 12:42 UTC | |
by btobin0 (Acolyte) on Dec 08, 2007 at 06:48 UTC | |
by btobin0 (Acolyte) on Dec 08, 2007 at 09:29 UTC | |
by johngg (Canon) on Dec 08, 2007 at 12:09 UTC |