in reply to inplace file editing
$/ seems to work correctly, reading to the end of the file if set to undef. However, by setting $^I to the null string, Perl seems to think it is running as if at the command line. the "while(<>)" reads from the file named "test", but the print statement writes to that same file. I find that without STDOUT, file test is erased and filled with a single "hello". Using the STDOUT filehandle, the file is erased and set to 0 bytes. Do you see the same activity?#!/usr/bin/perl $ARGV[0]="test"; $^I=""; undef $/; while(<>) { print STDOUT "hello\n" }
What I don't get is by keeping the same program as above but inserting $^I=undef; just before the print statement inplace editing does not seem to get disabled, i.e. the file is overwritten anyway.
|
|---|