Programming Perl

Programming PerlSearch this book
Previous: 3.2.162 substrChapter 3
Functions
Next: 3.2.164 syscall
 

3.2.163 symlink

symlink OLDFILE, NEWFILE

This function creates a new filename symbolically linked to the old filename. The function returns 1 for success, 0 otherwise. On systems that don't support symbolic links, it produces a fatal error at run-time. To check for that, use eval to trap the potential error:

$can_symlink = (eval { symlink("", ""); }, $@ eq "");

Or use the Config module. Be careful if you supply a relative symbolic link, since it'll be interpreted relative to the location of the symbolic link itself, not your current working directory.

See also link and readlink earlier in this chapter.


Previous: 3.2.162 substrProgramming PerlNext: 3.2.164 syscall
3.2.162 substrBook Index3.2.164 syscall