in reply to Difference btw. abs_path and $0?
This is how I like to do that kind of thing–
use strictures; use Path::Class "file"; use File::Spec; my $script = file( File::Spec->rel2abs(__FILE__) ); print $script, $/; printf("HURR -> %s\nDERR -> %s\nDERP -> %s\n", $script->basename, $script->parent, $script->as_foreign("Win32"), ); __END__ /Users/moo/depot/tmp/pm-972505.pl HURR -> pm-972505.pl DERR -> /Users/moo/depot/tmp DERP -> \Users\moo\depot\tmp\pm-972505.pl
You can chain ->parent and use the methods like relative to do lots of easy to follow path handling code; Path::Class::File, Path::Class::Dir. Sidenote: cd'ing around in scripts, to me, has a pretty strong code smell and whenever I see it in the wild it seems to come with too many assumptions and too little error checking.
|
|---|