in reply to Turning pathname into package name in a portable way
use File::Spec; my ($volume, $dirstring, $file) = File::Spec->splitpath($pathname); my @dirs = File::Spec->splitdir($dirstring); # Unfortunately, splitpath's doc says: # The directory portion may or may not be returned with a trailing + '/'. # # Which 'may or may not' give us an extra 'null' member of # @dirs, because splitdir allows null directory names. # # Hence this next line, purely for cleanup: pop @dirs if ($dirs[-1] eq ''); $file =~ s/\.pm$//; my $package = join('::',@dirs,$file);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Turning pathname into package name in a portable way
by itub (Priest) on Oct 15, 2005 at 22:30 UTC | |
by EvanCarroll (Chaplain) on Oct 15, 2005 at 23:06 UTC |