in reply to Modify file without any temp variable

Here's another approach:

my @orig = ($/, $\); undef($/); undef($\); open (JE, $file) || die "Cannot open $file"; (my $j = <JE>) =~ s/orig/new/g;

At this point you can either:

close (JE); open (JE, "> $file); print JE $j; close (JE); ($/, $\) = @orig;

or, more efficiently:

seek (JE, 0, 0); print JE $j; close (JE); ($/, $\) = @orig;