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 script dump some database structures to files, each file for each
table, and then I want to edit those files, but couldn't make the
edition infile, and do not want to duplicate files for just editing them
(using $^I).
Is there any way to open a file for input and output at the same time?
This is just and example, and doesn't work, but may be it explains
better what I'm trying to do:
while (glob "*.dump") { #I know there is not a "<>"
open (TMPFILE,"<&>", $_) or die "Could not open file $_: $!\n";
while (<TMPFILE>) {
s/^--.*//;
print;
}
}
Cheers
MartÃn
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/