cute wrote:
Now i create a temp file to store changed content.

perldoc -q "How do I make a temporary file name"


is there a simple way to change file content without creating temp
files?

ie:

while(<>)
{
  tr/[a-e]/[1-5]/g

Why are you changing all '[' to '[' and all ']' to ']'? There is no /g option with the tr/// operator. It looks like you want:

     tr/a-e/1-5/;

  print TEMP, $_

Do you really want to print the string 'TEMP' in front of every line? You should really enable the warnings and strict pragmas.


}

use warnings;
use strict;

$^I = '.bak';

while ( <> ) {
    tr/a-e/1-5/;
    print;
    }

__END__

That does what you want but it also creates a temporary file, it just hides the details from you.




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to