amma has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Filehandle problem
by Random_Walk (Prior) on May 07, 2013 at 11:18 UTC | |
by amma (Novice) on May 07, 2013 at 11:22 UTC | |
by Random_Walk (Prior) on May 07, 2013 at 11:28 UTC | |
by amma (Novice) on May 07, 2013 at 11:38 UTC | |
by Random_Walk (Prior) on May 07, 2013 at 11:55 UTC | |
| |
|
Re: Filehandle problem
by jnyman (Acolyte) on May 07, 2013 at 11:43 UTC | |
|
Re: Filehandle problem
by graff (Chancellor) on May 07, 2013 at 23:22 UTC | |
by jnyman (Acolyte) on May 08, 2013 at 07:49 UTC |