Martin Spinassi wrote:
Is there any way to open a file for input and output at the same time?

Yes. Open it with the '+<' MODE.

    open my $fh, '+<', $file or die "Couldn't open $file: $!";
    my @keep;
    while ( <$fh> ) {
        next if /^--/;
        push @keep, $_;
    }
    seek $fh, 0, 0;
    truncate $fh, 0;
    print $fh @keep;

http://perldoc.perl.org/functions/open.html

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to