in reply to Using system (); with Strawberry Perl
Perhaps some code like this code for your first system call with grep?
I did not create the test files necessary to actually prove that this works on my Windows system, but this is plausible.
The above code will be slower than Unix grep -l because this code looks at every line of the input file and reports the number of lines that matched, and if >0, that fact causes the filename to be printed. grep -l stops at the first matching line and reports the file name. Speed depends upon how big your files are. A couple more lines of Perl code can emulate the exact grep -l functionality (stop reading the file when the first match is found). I have no idea what File::Grep is and why you would need it. Perl regex is very fast. Literally decades of tweaking have gone into the regex engine.#!/usr/bin/perl use strict; use warnings; use autodie; #system ('grep -l "DATAmessage.*3\.0" *.xml > 3.0_files_arraydata.txt' +); open my $OUT, '>', '3.0_files_arraydata.txt'; foreach my $filename (<*.xml>) { open my $in, '<', $filename; print $OUT "$filename\n" if grep{/DATAmessage.*3\.0/}<$in>; }
Anyway, try the above out and see how it goes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using system (); with Strawberry Perl
by hippo (Archbishop) on Nov 25, 2021 at 10:34 UTC | |
|
Re^2: Using system (); with Strawberry Perl
by hadrons (Novice) on Nov 25, 2021 at 19:15 UTC | |
by Marshall (Canon) on Nov 26, 2021 at 20:04 UTC |