in reply to Re: Symbolic Link
in thread Symbolic Link

sub utilGetAbsoluteFileName{ my $fileName = shift; $fileName =~ s/\/+/\//g; if(! -e $fileName){ return $fileName; } my $dir = getcwd; if ($fileName !~ /^\//){ $fileName = $dir."\/".$fileName; } my @targetArr = (); my @fileArray = split "\/", $fileName; for (my $index=0; $index<@fileArray; $index++){ next if($fileArray$index eq "\."); if($fileArray$index eq "\.\."){ pop @targetArr; }else{ push @targetArr, $fileArray$index; } } my $absFileName = join "/", @targetArr; $absFileName =~ s/\/+/\//g; return $absFileName; } I have written this API which calculates the absolute path for any filename in unix. It takes care of "../../" and "./". Please tell if i have missed any case. Thanks

Replies are listed 'Best First'.
Re^3: Symbolic Link
by Anonymous Monk on May 21, 2009 at 09:17 UTC