perl function readlink
www.itfigidea.com
The readlink
function in Perl returns the value of a symbolic link. It takes one argument which is the path of the symbolic link. If successful, it returns the value of the symbolic link. If there is an error, it returns undef
.
Here is an example:
my $link = readlink("/usr/bin/perl"); if (defined $link) { print "The value of /usr/bin/perl symbolic link is: $link\n"; } else { print "Could not read the symbolic link: $!\n"; }
In this example, the readlink
function is called with the path /usr/bin/perl
. If the function is successful in reading the value of the symbolic link, it is stored in the variable $link
. The defined
function is used to check if the value of the symbolic link is defined. If it is, the value is printed. Otherwise, an error message is printed along with the error message that was returned by readlink
.