Parser

anoop4real's Avatar, Join Date: Dec 2006
Light Poster
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's Avatar, Join Date: Apr 2005
Team Leader
You want the directory listing?
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
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");
    }
}
}
ungalnanban's Avatar, Join Date: Feb 2010
Go4Expert Member
Mr.Murugaperumal Why you are posting same answer twice?

Before Submit your answer see your Preview Image