On 05/22/2014 05:51 PM, Andy Bach wrote:
On Thu, May 22, 2014 at 4:37 PM, Charles DeRykus <[email protected]> wrote:


I was just fiddliing w/ that too and, creating a sym link behaves different
than a hard link but:

as you should know those are very different animals

$ ln nohup.out st
$ perl -e '$fname = "st"; print "yes\n"  if ( -l $fname  and  not -f _ )'
$ perl -e '$fname = "st"; print "yes\n"  if ( -f $fname  and  not -l _ )'
The stat preceding -l _ wasn't an lstat at -e line 1.

that makes sense. lstat is a special call that does a stat and also checks for a symlink. the whole idea of regular stats (and other fiel system calls) is that they follow symlinks internally at all levels. ONLY an lstat is able to see whether something is a symlink and what its value is (where it points to).

$ rm st
$ ln -s nohup.out st
$ perl -e '$fname = "st"; print "yes\n"  if ( -l $fname  and  not -f _ )'
yes
$ perl -e '$fname = "st"; print "yes\n"  if ( -f $fname  and  not -l _ )'
The stat preceding -l _ wasn't an lstat at -e line 1.

it doesn't matter what the file is. the regular stat doesn't set the stat buffer in a way the -l can use. so it is an error. the -l sets the stat buffer and _ is fine for -f to use.


Not sure why a "-f" isn't an lstat

because of what i said above. the design of symlinks is that all other calls behave just like the symlink didn't exist.

uri


--
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to