On Jul 2, 11:46 am, [EMAIL PROTECTED] (Rob Dixon) wrote:
>
> This seems to do the job. Hope it helps.
>
> Rob
>
> sub canonical_path {
>
>   my $path = shift;
>   my @path;
>
>   foreach (File::Spec->splitdir($path)) {
>     if ($_ eq '..') {
>       if ($path[-1] eq '..') {
>         push @path, $_;
>       }
>       else {
>         pop @path;
>       }
>     }
>     elsif ($_ ne '.') {
>       push @path, $_;
>     }
>   }
>
>   File::Spec->catdir(@path);
>
> }

Hi,

Pardon me for being dense, but I can't figure out a case where

>       if ($path[-1] eq '..') {

would ever be true.

--
Brad


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to