chinamox has asked for the wisdom of the Perl Monks concerning the following question:
Brothers I have sinned - but I know not how!
I am trying to use File::Basename to get the file name from a path passed into the program via $ARGV1.
$org_fn = $ARGV[1]; ($file,$dir,$bak) = fileparse("/tmp/file.bak", qr/~+$/, qr/\.(bak|orig|save)/) print "$file \n";
The output comes out as either 'path/path/path/file.ext' or '$ARGV' (when I used single quotes, which I see is wrong now). While I dug the regex out of O'reilly's Perl Cookbook, I now think I am asking fileparse() to do something with $ARGV that is either impossible or even sinful. Is this correct? How can get the filename I want?
Thank you,
-mox
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using File::Basename and $ARGV[]
by liverpole (Monsignor) on Oct 23, 2006 at 15:09 UTC | |
by chinamox (Scribe) on Oct 23, 2006 at 15:23 UTC | |
|
Re: Using File::Basename and $ARGV[]
by davorg (Chancellor) on Oct 23, 2006 at 15:10 UTC | |
by chinamox (Scribe) on Oct 23, 2006 at 15:30 UTC | |
by blazar (Canon) on Oct 24, 2006 at 10:44 UTC |