in reply to Capture Contents AND Overwrite without Opening Twice?

[mmartin:

It's pretty simple, as the AMs have indicated. I wrote a quickie program to illustrate:

$ perl tuv.pl $ cat tuv.pl print $FH reverse @lines; seek $FH, 0, 0; my @lines = <$FH>; open my $FH, '+<', $0; use warnings; use strict;

I could've printed the program *before* running it, but (a) I'd've had to print it twice to show that it did anything, and (b) it would have been less amusing. ;^)

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Capture Contents AND Overwrite without Opening Twice?
by Anonymous Monk on Oct 08, 2014 at 21:12 UTC

    I love it :-) It gets even better if you change $FH to a bareword filehandle FH, then the resulting code remains runnable, albeit useless ;-)