Re: Editing file

2009-03-20 Thread Martin Spinassi
On Fri, 2009-03-20 at 11:07 -0700, John W. Krahn wrote: > Martin Spinassi wrote: > > Hi list! > > Hello, > > > I've just started with perl, but I'm really excited about its power. > > I'm excited that you're excited! ;-) I'm excited because you are excited because I'moryou. doesn't

Re: Editing file

2009-03-20 Thread Martin Spinassi
On Fri, 2009-03-20 at 18:48 +0100, Gunnar Hjalmarsson wrote: > 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 (

Re: Editing file

2009-03-20 Thread John W. Krahn
Martin Spinassi wrote: Hi list! Hello, I've just started with perl, but I'm really excited about its power. I'm excited that you're excited! ;-) I'm trying to edit a file, but couldn't find out how to do it without making a temp file. I've been searching for the solution, but all I find

Re: Editing file

2009-03-20 Thread Gunnar Hjalmarsson
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

Editing file

2009-03-20 Thread Martin Spinassi
Hi list! I've just started with perl, but I'm really excited about its power. I'm trying to edit a file, but couldn't find out how to do it without making a temp file. I've been searching for the solution, but all I find is how to do it from command line, adding a "-i" to the execution. My scrip