The complement to basename that arturo forgot
to mention is dirname, so your code would look like this:
$a = "/root/subroot/subsubroot/filename";
$b = dirname $a;
$c = basename $a;
That said, do not get into the habit of using variables $a and $b. You are much better off giving them descriptive names,
which will help your code self-document itself.
A better way of writing your code would be
my $filespec = "/root/subroot/subsubroot/filename";
my $path = dirname $filespec;
my $filename = basename $filespec;
|