Perl script that resolves all symbolic links and paths.

#!/usr/bin/perl
#
# Determines a file or directory real or absolute path.
#
# Usage:
#   realfilepath.pl --path file
#
# Example:
#   $ realfilepath.pl --path /var
#   outputs: /private/var
#
# Ref:
# http://www.cyberciti.biz/faq/unix-linux-bsd-find-real-physical-path/
#
use Cwd 'abs_path';

if (@ARGV != 2 ) {
  print "Usage: $0 --path filen";
  exit;
}

$realfilepath = abs_path("$ARGV[1]");

if (-e $realfilepath) {
  print "$realfilepathn";
}