One thing that always gets me is how to convert a given path - be it absolute, relative or whatever - into an absolute path on the filesystem. It turns out there's a perl module that can do exactly this, and so I've just rolled a tiny script that makes use of this and converts it's first parameter into a real path - an absolute path on the filesystem regardless of where it came from, and without any extra . or .. elements in there.
The script does require the File::PathConvert module to be installed before it will work, but then you can just drop it into /usr/local/bin or wherever and do magic with it exactly the same as dirname or basename.
#!/usr/bin/perl -w
use File::PathConvert qw(realpath);
if (@ARGV==0)
{
print "Usage: realpath \n";
exit();
}
my $in = $ARGV[0];
my $outpath = realpath($in);
print $outpath;