Hi All,
I am new to perl and facing an interesting situation.
There are 2 conditions to be matched in my code.
1. If the first condition is matched, then the 3 lines following that condition should be printed.
2. If the second condition is matched, then the 12-15 lines below that must be printed.
For the first case its working fine. But for the second case, it is printing only 4 lines.
Here is the extract of that code::
@fcontent=<IN>;
while(@fcontent){
$line = shift(@fcontent);
if($line =~ m/<pattern1>/)
{
(@line)= split(' ', $line);
$len=@line;
$i=0;
while ($i <= $len) {
print OUT $line;
$line = shift(@fcontent);
$i++;
}
print OUT "\n";
}
if($line =~ m/<pattern2>/)
{
(@line)= split(' ', $line);
$len=@line;
$i=0;
while ($i <= $len) {
print OUT $line;
$line = shift(@fcontent);
$i++;
}
print OUT "\n";
}
}
I am new to perl and facing an interesting situation.
There are 2 conditions to be matched in my code.
1. If the first condition is matched, then the 3 lines following that condition should be printed.
2. If the second condition is matched, then the 12-15 lines below that must be printed.
For the first case its working fine. But for the second case, it is printing only 4 lines.
Here is the extract of that code::
@fcontent=<IN>;
while(@fcontent){
$line = shift(@fcontent);
if($line =~ m/<pattern1>/)
{
(@line)= split(' ', $line);
$len=@line;
$i=0;
while ($i <= $len) {
print OUT $line;
$line = shift(@fcontent);
$i++;
}
print OUT "\n";
}
if($line =~ m/<pattern2>/)
{
(@line)= split(' ', $line);
$len=@line;
$i=0;
while ($i <= $len) {
print OUT $line;
$line = shift(@fcontent);
$i++;
}
print OUT "\n";
}
}