On Monday 14 January 2002 02:25 am, I wrote: > On Monday 14 January 2002 02:07 am, you wrote: > > Hi, I wanted to do this: > > ln -s X Y but unless it don't already exists? > > How can I do this in Perl? > > Thanks > > Using the normal file testing in Perl I think this'd work: > > if (-l $filename) { > # do stuff here > } > > that's a dash then the letter "L" in lowercase. However this won't tell > you if there's already a normal file with that name. You may also want to > add a test using -e to make sure a file with that name doesn't exist. > > Steven
So to answer your question my $filename = "Y"; unless (-l $filename or -e $filename) { symlink "X", "Y" or warn "Couldn't create symbolic link "Y" to "X": $!"; } NOTE: it's not necessary to make $filename = "Y". I only though it'd be easier to see what I was doing than (-l "Y" or -e "Y") Steven -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]