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

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

From:
Rafael Garcia-Suarez
Date:
September 23, 2003 06:29
Subject:
Re: [perl #24000] perl -pi -e s:foo:foo2: FILE mishandles symlinks?
Message ID:
20030923152346.480f8c47.rgarcia@hexaflux.com
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 FollowSymlinks.pm file, to be loaded via
"PERL5OPT=-IFollowSymlinks".]



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About