in reply to Complex string parsing
my $path = '/path/to/some/file.txt'; my $file = '/path/to/some/directory/'; my $dir; for ($path, $file){ # if you know the dirs will always have a trailing slash # otherwise if (-d $_){ if (m!/$!){ $dir = (split /\//)[-1]; } else { # else its a file } } print $dir, "\n";
--
my $chainsaw = 'Perl';
|
|---|