Just open an output file and print whatever you want to save off to that handle. perldoc perlopentut and perldoc -f open will explain more.
Also, a style nit: using -r and friends on files you're about to open is redundant. Just open them and then deal with that failing.
open( FILE, $filename ) or die "Can't open $filename for reading: $!\n"; ...
Or something like this which is handy when you're looping over several files
foreach my $filename ( @files ) { unless( open( FILE, $filename ) ) { warn "Couldn't open $filename: $!\n"; next; } ... close( FILE ); }
Not using the test operators gets even more important when you get into writing files, since test-then-open isn't an atomic operation and you leave yourself open to race conditions.
In reply to Re: simple regex question
by Fletch
in thread simple regex question (parsing and saving a file)
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |