[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [MacPerl] Changing a file (pseudo) in-place?



Tim Endres <time@ice.com> in message <01BC13AC.C574F390@pc.ice.com> writes:

>This is addressed on page 332 of the new Camel book. If you provide
>the "-i" switch with no extension, then you do not get a backup file and
>do not have to do the unlink of the backup file. Since 'undef-ing' $^I is
>supposed to turn off inplace editing, I suspect that  $^I = "";  would be
>the equivalent of "-i", and thus the script might reduce to simply:
>
>        $/ = "\012";
>        $^I = "";
>        while ( <> ) { s/\012/\015/g; print; }

I find this results in a MacPerl error. There seems to be no way that the
creation of a back-up file can be avoided in MacPerl.

If S^I is set to 'undef' then MacPerl ignores it (as it should according to
PP page 137). $^I = "" does not behave in the same way as $^I = undef.

It seems therefore that -i with no extension (in Unix Perl) does not have
the same effect as $^I = "" in MacPerl. But perhaps it doesn't in Unix Perl
either?

Alan Fry.