N
nani
Problem Def: copy the pattern which before ",(comma)" and find a
matching pattern in another file.
status: i wrote following code. but it is not working properly. plz
help me.
#! C:\Perl\bin\perl.exe
print "hello\n";
print "Please Enter Input File name(Give the complete path):";
$infile=<STDIN>; #give the input file name here
chomp($infile);
open ($in, "<", $infile) or die "Cannot open file for reading\n";
#Check whether the file can be opened for reading
while (<$in>)
{
if(/,/) {print "before match: $`\t and after match: $'\n\n";};
$x=$';
$y=$`;
&mysubroutine($x,$y);
}
sub mysubroutine
{
$a=$x;
$b=$y;
print "Please Enter the Output File name (Give the compelte path):";
$infile=<STDIN>; #give the output file name here
chomp($infile);
open ($in, "<", $infile) or die "cannot open file to write\n";
#Check whether the file can be opened for writing
print "$b\n";
while (<$in>)
{
print "pattern to find: $y\n";
if (/$b/) {print "Cheers@\n";};
}
close $in or die "cannot close $out\n";
}
close $in or die "Cannot close $in\n";
matching pattern in another file.
status: i wrote following code. but it is not working properly. plz
help me.
#! C:\Perl\bin\perl.exe
print "hello\n";
print "Please Enter Input File name(Give the complete path):";
$infile=<STDIN>; #give the input file name here
chomp($infile);
open ($in, "<", $infile) or die "Cannot open file for reading\n";
#Check whether the file can be opened for reading
while (<$in>)
{
if(/,/) {print "before match: $`\t and after match: $'\n\n";};
$x=$';
$y=$`;
&mysubroutine($x,$y);
}
sub mysubroutine
{
$a=$x;
$b=$y;
print "Please Enter the Output File name (Give the compelte path):";
$infile=<STDIN>; #give the output file name here
chomp($infile);
open ($in, "<", $infile) or die "cannot open file to write\n";
#Check whether the file can be opened for writing
print "$b\n";
while (<$in>)
{
print "pattern to find: $y\n";
if (/$b/) {print "Cheers@\n";};
}
close $in or die "cannot close $out\n";
}
close $in or die "Cannot close $in\n";