Amaninder said:
Can anyone tell whats the difference between first two and last two of
the following variables. What does it mean by "all links resolved" . I
am new to perl.
Not especially relevant, because "links" have nothing to do with Perl.
They are a generic Unix concept.
$Bin - path to bin directory from where script was invoked
$Script - basename of script from which perl was invoked
$RealBin - $Bin with all links resolved
$RealScript - $Script with all links resolved
It means that if $Bin or $Script contain any symlinks, $RealBin and
$RealScript will have all those symlinks replaced with whatever they
actually link to. A "link" is a way of giving a different name to an
existing file or directory.
For example, consider a directory with three folders:
$ ls -l
total 6
drwxrwxr-x 3 plalli devel 512 Jul 13 14:31 f1
drwxrwxr-x 2 plalli devel 512 Jul 13 14:31 f2
drwxrwxr-x 2 plalli devel 512 Jul 13 14:31 f3
The f2 folder contains two files:
$ ls -l f2
total 0
-rw-rw-r-- 1 plalli devel 0 Jul 13 14:31 four.txt
-rw-rw-r-- 1 plalli devel 0 Jul 13 14:31 three.txt
Now I create a symlink to the f2 directory:
$ ln -s f2 new_folder
If I look at the main directory again, I see:
$ ls -l
total 8
drwxrwxr-x 3 plalli devel 512 Jul 13 14:31 f1
drwxrwxr-x 2 plalli devel 512 Jul 13 14:31 f2
drwxrwxr-x 2 plalli devel 512 Jul 13 14:31 f3
lrwxrwxrwx 1 plalli devel 2 Jul 14 11:41 new_folder -> f2
Notice how the new_folder entry is "pointing" to f2? That means it's a
different name for an existing entry. If I then look at the contents
of new_folder, I'll see the contents of f2:
$ ls -l new_folder/*
-rw-rw-r-- 1 plalli devel 0 Jul 13 14:31
new_folder/four.txt
-rw-rw-r-- 1 plalli devel 0 Jul 13 14:31
new_folder/three.txt
So that's your brief overview of symlinks. In your specific case, if
FindBin had told you that $Bin contains a path with new_folder in it,
$RealBin would contain that same path, but with new_folder replaced by
f2.
Hope this helps,
Paul Lalli