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';
In reply to Re: Complex string parsing
by greenFox
in thread Complex string parsing
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |