Dear All,
I want to write a perl script which can parse (retrieve) specific information from all the files in a folder with a particular extension.
i.e in a Folder I have files with the following extension .xyz
Now i wish to write a script which could parse all the files in this folder.
For a Single File I can easily do this by a script like this one.
But I want to automate this so that It can read every file with a particular extension in my folder.
# record user input and store in a variable using
$myanswer=<STDIN>;
# defined a new veriable for file name
$myfilename=$myanswer ;
# open the file if available in the directory otherwise die
open (SP, "$myfilename") or
die "Your desired file $myfilename is not found in the directory, please correct if this is a typo, or search an other directory\n";
# open the new output file to be saved in HTML format
open(OUTPUT,">output.txt");
while (<SP>){
if ($_=~/sometext/ )
{
printf(OUTPUT " <li> $1 </li>");
print (OUTPUT "<br>\n");
}
}
# close the open file handels
close SP;
close OUTPUT;
Please reply me as early as possible
Regards
I want to write a perl script which can parse (retrieve) specific information from all the files in a folder with a particular extension.
i.e in a Folder I have files with the following extension .xyz
Now i wish to write a script which could parse all the files in this folder.
For a Single File I can easily do this by a script like this one.
But I want to automate this so that It can read every file with a particular extension in my folder.
# record user input and store in a variable using
$myanswer=<STDIN>;
# defined a new veriable for file name
$myfilename=$myanswer ;
# open the file if available in the directory otherwise die
open (SP, "$myfilename") or
die "Your desired file $myfilename is not found in the directory, please correct if this is a typo, or search an other directory\n";
# open the new output file to be saved in HTML format
open(OUTPUT,">output.txt");
while (<SP>){
if ($_=~/sometext/ )
{
printf(OUTPUT " <li> $1 </li>");
print (OUTPUT "<br>\n");
}
}
# close the open file handels
close SP;
close OUTPUT;
Please reply me as early as possible
Regards