Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Parser (http://www.go4expert.com/forums/parser-t4011/)

anoop4real 25Apr2007 12:17

Parser
 
Hi all,
Can any one tell me how to parse all the files (*.txt ,*.xml etc) in a folder by taking the folder name as argument and to search for a particular word in that files , I want to write a perl scipt for this, pls give me some pointers.

Regards,
Anoop4real

pradeep 25Apr2007 14:50

Re: Parser
 
You want the directory listing?

murugaperumal 25Feb2010 15:51

Re: Parser
 
Dear Friend,

The following coding is used to give your requirement
Code:

use strict;
use warnings;
use Data::Dumper;
my $var;
foreach(@ARGV)
{
opendir(DIR,$_);
my @array=readdir(DIR);
foreach(@array)
{
    $var=$_;
    if($var=~/(\.txt|\.xml)/)
    {
    system("grep -lh 'welcome' $var");
    }
}
}

:crazy:

ungalnanban 25Feb2010 15:59

Re: Parser
 
Mr.Murugaperumal Why you are posting same answer twice?

Before Submit your answer see your Preview Image


All times are GMT +5.5. The time now is 21:03.