On May 11, Zapp (Zapp) wrote:
Does anyone has a better idea?
#!/usr/bin/perl
use strict;
use warnings FATAL => 'all';
use Cwd qw(getcwd);
my $cwd = getcwd();
print map { -e "$cwd/$_" ? "$cwd/$_\n" : "$_\n" } @ARGV;
Or use rel2abs in the core File::Spec module.
--
Magnus Woldrich
On 12-05-11 05:14 AM, Zapp wrote:
> Does anyone has a better idea?
Yes, use Cwd::realpath() See `perldoc Cwd` for details.
--
Just my 0.0002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
[updated for today's programming]
I have a path like
"/root/Tools/Log/../../Bin2/Patch/../Settings/ServerInfo/", and it's
absolute path should be "/root/Bin2/Settings/ServerInfo".
and I use these codes to get what I want.
my $my_str = "/root/Tools/Log/../../Bin2/Patch/../Settings/ServerInfo/";
Replace_it: $my_str =~ s#[^\./]+/\.\.