split is a perl command!
Code:
#!/usr/bin/perl
$l_dir="/My/Dir/is/much/longer/than/yours/but/who/cares";
@l_dir_path=split(/\//, $l_dir);
for ($i=1; $i<@l_dir_path; $i++) {
print "dir$i=$l_dir_path[$i]\n";
}
An array starts at position 0, however in this case the first entry in the array would be blank.
This is due to the / at the beginning of the string, therefore I am starting $i with a value of 1.