Chovy’s Blog

Converting paths to absolute in Perl

Fri, January 14, 2005 — Category: Personal

Here’s a quick fix when working with command line parameters in Perl that will take paths, absolute or relative, as an argument.
For example you execute your script like so:
$./foo.pl -path ./my/path
$./foo.pl -path ../../some/path
$./foo.pl -path /absolute/path
All of which could be possible paths entered by users, you want to support all of them and convert them all […]

Here’s a quick fix when working with command line parameters in Perl that will take paths, absolute or relative, as an argument.

For example you execute your script like so:

$./foo.pl -path ./my/path

$./foo.pl -path ../../some/path

$./foo.pl -path /absolute/path

All of which could be possible paths entered by users, you want to support all of them and convert them all to absolute paths in your script. This ensures you script can be called from anywhere, and accept any path given.

– begin scrip –

#!/usr/bin/perl

use Cwd ‘abs_path’;

my $root = $ARGV[1];

$root = abs_path($root);

print “$root\n”;

– end –

Should always print an absolute path, ie- starting with the full path “/some/path”.

  • Post Converting paths to absolute in Perl to del.icio.us
  • Post Converting paths to absolute in Perl to digg
  • Post Converting paths to absolute in Perl to Furl
  • Add Converting paths to absolute in Perl to YahooMyWeb
  • Simpify!
  • Post Converting paths to absolute in Perl to shadows
  • Post Converting paths to absolute in Perl to Spurl
  • Post Converting paths to absolute in Perl to BuddyMarks
  • Submit Converting paths to absolute in Perl to Slashdot

3 Comments »

213

Comment by Anonymous

March 14, 2005 @ 3:11 pm

Handy. Thanks for the tip. Scott

Trackback by Anonymous

December 12, 2007 @ 10:05 pm

Naked Gilrs Indians…

Telling philip county naked gilrs indians plastic determined. Chloe Dior Szilvia Lauren throughout meanwhile cutting naked gilrs indians Klara Smetanova two. …

Trackback by Anonymous

January 1, 2008 @ 4:14 am

jeans-pony girl gallery…

jeans-pony girl gallery…

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

 
Keyword Advertisers:
SEO Directory SEO Links Free Link Directory Shopping Submission Directory Gardening Tips Political Forum Search Engine Optimization Search Engine Marketing Audio Video Directory SEO Forum Web Development Blog Organic SEO Wiki Web Development Consulting

Learn more about purchasing keyword text link ads on this site.