Hi all,
I wrote a script to search a pattern in input file and if pattern does not found in input file ,print that pattern in to output file.
The input file is
--------------------------------------------------------
1999-1011ğAll the flowers of tomorrow are in the seeds of today.
2000-1209ğI saw this article posted on another site and wanted to share it with everyone at TSDN. Please read this article and post your thoughts.
1999-1041ğAll the flowers of tomorrow are in the seeds of today.
2000-1367ğI saw this article posted on another site and wanted to share it with everyone at TSDN. Please read this article and post your thoughts.
2000-6646ğI saw this article posted on another site and wanted to share it with everyone at TSDN. Please read this article and post your thoughts.
2000-6463ğI saw this article posted on another site and wanted to share it with everyone at TSDN. Please read this article and post your thoughts.
----------------------------------------------------------
The pattern i want to find is 1999-1041
The script I wrote is-
open (RD, "input.txt") or die;
@Read = <RD>; close (RD);
open (WR2, ">>output.txt") or die;
$count=0;
$C="1999-1041";
for ($read=0; $read <= $#Read; $read++)
{
if($Read[$read] !~ /$C/)
{
$count++;
print WR2"$count=$C\n";
}
}
---------------------------------------------
The output I got is
1=1999-1041
2=1999-1041
3=1999-1041
4=1999-1041
5=1999-1041
That means it search 6 lines in input file and found 5 lines which does not contain pattern,thats why it prints pattern 5 times to output file.
But actually the required output is none as pattern is present in input file.
Need guidelines regarding this ..
--Mahesh