On Oct 11, 2:37 pm, [EMAIL PROTECTED] (PeiYu Zeng) wrote:
> Hello,
>
> Can I modify the contents of a file, without creating a new one?
This is called inplace editing Possible but not recommended.
do this
{
local(@ARGV) = ($file);
$^I='.BAK'; # see perdoc perlvar
while(<>){
# Do edit here
s/\s+$/\n/; # For eg Trim all extra spaces in the end
print; # Dont forget this
}
}
------------------------
This should work
Thanks
Ram
Note To spammers:
[EMAIL PROTECTED]
http://pragatee.com
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/