For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > canonpath









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author canonpath
Derek B. Smith

2006-10-06, 6:57 pm

I dont understand what the point of canonpath is here:
It seems to me canonpath only appply so links.

##-- Show me all installed Modules --##
use File::Find 'find';
use File::Spec::Functions;
print "Your installed modules on $^O are:\n";
print "-" x 38,"\n";
find { wanted => sub { print canonpath "$_\n" if
/\.pm\z/ },
no_chdir => 1},
@INC;

#canonpath

I tried code with/out canonpath and the output is the
same.

I then lookup canonpath on CPAN and it tells me

*** No physical check on the filesystem, but a logical
cleanup of a path.

$cpath = File::Spec->canonpath( $path ) ;

Note that this does *not* collapse x/../y sections
into y. This is by design. If /foo on your system is a
symlink to /bar/baz, then /foo/../quux is actually
/bar/quux, not /quux as a naive ../-removal would give
you. If you want to do this kind of processing, you
probably want Cwd's realpath() function to actually
traverse the filesystem cleaning up paths like this.

thank you
derek


________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com