I changed my code a little bit. I am moving selective contents of the array into files (A1 and A2). I now want to process these files. But when i run the code, the control never goes to the while loop although i am able to see these files created. I am unable to understand this behaviour. Please help me on this.
open(f1,"input.log");
open(f2,"+> A1.log");
open(f3,"+> A2.log");
@array = <f1>;
for my $num(0..$#array)
{
if($array[$num] =~ /String 1/)
{
for my $tnum(1..4)
{
printf(f2 "%s\n",$array[$num+$tnum]);
}
}
elsif($array[$num] =~ /string 2/)
{
for my $tnum(0)
{
printf(f3 "%s",$array[$num]);
}
}
}
while(<f3>) {
if($_ == /string 3/) {
@temp = split(/\W+/, $_);
$time_stamp = $temp[1];
print "$time_stamp\n";
}
}