diamondsandperls has asked for the wisdom of the Perl Monks concerning the following question:
my @patterns = ( qr/Record contentId\=\"\d+\"/ ); my $final_file = "C:/Users/$sso/Desktop/archer_$searchid.txt"; open(my $final_fh, '>', $final_file) or die "Failed to open $final_file - $!"; open(my $input_fh, '<', $output_file) or die "Failed to open $output_file: $!"; while (<$input_fh>) { foreach my $pattern (@patterns) { print {$final_fh} $pattern, "\n"; } } close $final_fh;
With the following code when printing I get the following output. I am thinking I am doing something wrong with the following in storing regex matches, but not sure.
my @patterns = ( qr/Record contentId\=\"\d+\"/ );
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
(?-xism:Record contentId\=\"\d+\")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storing regex values in an array and processing the array
by choroba (Cardinal) on Jun 07, 2013 at 17:48 UTC | |
|
Re: Storing regex values in an array and processing the array
by 2teez (Vicar) on Jun 07, 2013 at 18:18 UTC | |
|
Re: Storing regex values in an array and processing the array
by Laurent_R (Canon) on Jun 07, 2013 at 18:52 UTC | |
by diamondsandperls (Beadle) on Jun 07, 2013 at 18:58 UTC |