open (my $rfh,'<', $entry) or die "cannot open > $entry: $!"; open(my $new, '>', "$name\_new.txt") or die "cannot open: $!"; my @data = <$rfh>; foreach my $l (@data) { if ($l =~ m/$signal2\(\d+\).*\s*<=\s*$signal1\(\d+\).*/){ my $i; for($i=0;$i<7;$i++){ my $j = $i + 1; print $new "$signal2\_rrfa_$label($j) <= $signal1\_rrfa_$label($i);\n" +; } $required_line = $&; } else{ print $new $l; } } close($new); close($rfh2);
My new file does not contain the lines from the original file when the if condition fails ( I mean the else part is not executed). The new file has only lines when if conditioned passed.
In reply to Filehandle problem by amma
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |