Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

When I use the code below.

open(FILEOPENED, "$fileopened") || die "couldn't open the file! $!"; while ($data = <FILEOPENED>) { print $data; } close(FILEOPENED); }

If $fileopened contains an alias as a path to the file i want to open (rather then a real link) , i get an error message.  Not a directory at rename.pl line 37.

How do I use an alias in the path to a file? Im using OS X 1.39.

Replies are listed 'Best First'.
Re: Alias's and file handles
by john_oshea (Priest) on Apr 09, 2006 at 13:06 UTC

    You're going to have to use one or more OSX-specific modules to determine if $fileopened is actually an alias or not, resolve it to the target file, then open that to read the contents. Unlike symbolic or hard links, the core Perl distribution has no idea what an 'alias' is.

    MacOSX::File::Info has a $finfo->flags method to determine if a file is an alias, but I can't see anything immediately obvious that will then resolve it to the final file.

Re: Alias's and file handles
by aufflick (Deacon) on Apr 10, 2006 at 00:09 UTC
    As per other posters, a MacOS "alias" doesn't work like a symbolic link in unix. On the other hand, if you do make a symbolic link on a MacOS volume (eg. in the terminal) then the Finder will work with it just like it works with Aliases.

    It's a pity that the two concepts are not unified - perhaps in a future version...

Re: Alias's and file handles
by richill (Monk) on Apr 09, 2006 at 12:15 UTC
    Do you mean softlinks