I am using File::Find to go through a very large tree.
I am looking for all xml files and open only those that contain a tag <Updated>. I then want to capture the contents of two tags <Old> and <New>.
My problem is, after I open the file and do the first grep for <Updated> (which does work), I am unable to grep again unless I close the file and open it.
I did something like this:
I gave up on using grep more then once and tried using while:
This also did not work.
If I close the file and open it again before the while statement, it works.
So....
1) Is there a way to grep the open file more then once and create $vars?
2) If not, is it better (faster) to write the file to a @list and then grep that rather then keep opening and closing the file?
I would rather grep then use "while" as that causes other headaches with the rest of the script.
Most of the files are fairly small.... but there will be many thousand of them.
Indeed File::Grep will open files for you. Here is a driver that lists data files, the perl code, and the results of counting lines in the files twice, then searching for a pattern in those same files:
producing:
Best wishes ... cheers, drl
Hi,
I am trying to capture the output of the an open pipe in perl. but I am not sure how to do this. can some one please help me do that?
Below is the script I am using (2 Replies)
I have been struggling to grep a file of NGrams (basically clusters of consonants or Consonant and Vowel) acting as a pattern file from an Input file which contains a long list of words, one word per line. The script would do two things:
Firstly read a text pattern from a large file of such... (5 Replies)
hi guys
i have this very messy script, that looks in /var/log/messages.all for an error and reports if it finds the key works
how can i get it to look at more then one file, i.e /var/log/message.all *
so it looks in old logs as well
thanks
exit 0 if (isRenderNode(hostname));
my... (4 Replies)
Not able to open a file using this code
why not?
use strict;
use warnings;
my $file = "verInfo.txt";
unless(open FILE, $file) {
# Die with error message
# if we can't open it.
die "\nUnable to open $file\n";
}
my $line = <FILE>;
print $line;
close FILE; (7 Replies)
First post, sorry to be a bother but this one has been dogging me. I have a process user (java application server) that trips a resource limit every couple weeks and need help finding what limit we're hitting.
First, this is what's running:
This is the error when jobs are run or the... (0 Replies)
Hi All,
I have a .TSV extension file having ~1 Gig data and I need to grep a pattern in that file using perl. I am not able to read the file using perl any suggestions on this/ If I Change the format my data gets mismangled so I am bothered about using specific format as well.
#!... (3 Replies)
Hi have one Perl file inside that i am defining
at an array file.
@temp_vmdk_files = `grep vmdk '$guest_vmx'`
where my $guest_vmx=/vmfs/volumes/47e40fec-9c8bb7f7-d076-001422159f8a/BES Exchange/BES-Exchange.vmx
and i am just want to do grep of "vmdk" files from the above path
but when... (5 Replies)
Hi All,
Can someone please help me write a script for the following requirement in awk, grep, sed or perl.
Buuuu xxx bbb
Kmmmm rrr ssss uuuu
Kwwww zzzz ccc
Roooowwww eeee
Bxxxx jjjj dddd
Kuuuu eeeee nnnn
Rpppp cccc vvvv cccc
Rhhhhhhyyyy tttt
Lhhhh rrrrrssssss
Bffff mmmm iiiii
Ktttt... (5 Replies)
hi
i am using perl on windows ( active state perl 5.8 ) and i want to check for Control-M (^M) in file. files to be checked are in unix format so new line character is (\n). This perl script is called from Batch file ( windows .BAT file )
my script is
while (<PROGRAM>) {
... (12 Replies)