develooper Front page | perl.perl5.porters | Postings from September 2003

Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?

Rafael Garcia-Suarez
September 23, 2003 06:29
Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
Pekka Savola (via RT) wrote:
> On Red Hat Linux 7.3 and 9 (perl 5.6.1 and 5.8, respectively), at least, 
> perl seems to be *seriously* mishandling symlinks with structures like 
> "perl -pi -e s:foo:foo2: FILE".  If FILE is a symlink, perl doesn't follow 
> it, causing a symlink being converted to a file in the directory where the 
> symlink resided in.

At first sight, I don't think perl should transparently follow symlinks.
That's not what I expect it to do. However this can be argued.

Note that you can force perl to follow symlinks by inserting at the top
of your script :

    BEGIN { @ARGV = map { -l $_ ? readlink : $_ } @ARGV; }

[You could even put this in a file, to be loaded via
"PERL5OPT=-IFollowSymlinks".] Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About