in reply to Re: Flip flop operator
in thread Flip flop operator

I don't have much expirience with PERL.
I need to take off specific lines from some file.
How should I do it?
Thanks in advance for the answer!

Replies are listed 'Best First'.
Re^3: Flip flop operator
by gellyfish (Monsignor) on Aug 19, 2004 at 11:23 UTC

    It is probably simpler to just slurp the entire file into an array and replace the while(<>) with an iteration over the array (untested code follows):

    my @data = <>; my $backup=$commandfile.".bak"; foreach $com (keys %hashnew) { $ARGV[0]="$backup"; $^I=".bak"; foreach (@data) { if ($hashnew{$com} == "all") { unless (/$hashnew{$com}/../\*\ Exit\ context\ \*/) { s/$com//g; } } if (/$hashnew{$com}/../\*\ Exit\ context\ \*/) { s/$com//g; } print; } }
    Of course if you actually explained to us what you want to do we might be able to come up with a better suggestion as it is not entirely clear from your code.

    /J\