On Friday, May 3, 2002, at 11:08 , Jerry Preston wrote:
> Hi!
>
> I am trying to determine if a is linked or not. I am using the following:
[..]
> I get the same result for two files! One is linked and the other is not.
let me offer you a bit of a basic case:
vladimir: 57:] ls -l *dos*
-rwxr-xr-x 1 drieux house 238 May 2 16:59 dos2unix
lrwxrwxrwx 1 drieux house 8 May 2 16:53 unix2dos -> dos2unix
vladimir: 58:]
one is a link the other is a file.
given
### #!/usr/bin/perl -w
### use strict;
###
### my @array = qw /dos2unix unix2dos/;
###
### foreach my $file (@array) {
###
### print "\t$file is a file\n"
### if ( -f $file ) ;
### print "\t$file is a link\n"
### if ( -l $file ) ;
### }
we get:
vladimir: 55:] perl testForLinks.pl
dos2unix is a file
unix2dos is a file
unix2dos is a link
vladimir: 56:]
remember that it is true that unix2dos is both a file and link.
let us modify our array to deal with
vladimir: 66:] ls -l lin* no*
lrwxrwxrwx 1 drieux house 7 May 3 12:28 linkTo -> nowhere
vladimir: 67:]
by adding in
my @array = qw /dos2unix unix2dos linkTo/;
and we get the information:
vladimir: 65:] perl *.pl
dos2unix is a file
unix2dos is a file
unix2dos is a link
linkTo is a link
vladimir: 66:]
notice that the linkTo nowhere is ONLY a link and not a link AND file.
ciao
drieux
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]