in reply to Using File::Basename and $ARGV[]

Hi chinamox,

I think what you want is simply:

use strict; use warnings; use File::Basename; $org_fn = $ARGV[1]; my $base = basename $org_fn; print "Basename is $base\n";

Note that File::Basename is a great way to get the name of the script itself, too.

I usually do this:

my $iam = basename $0; my $syntax = " syntax: $iam ... ";

and then don't have to worry about changing the program name; the syntax message stays correct.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: Using File::Basename and $ARGV[]
by chinamox (Scribe) on Oct 23, 2006 at 15:23 UTC

    Thank you, that is exactly what I wanted! I figured I was trying a little to hard and just needed nudge in the right direction. Also thank you for the excellent tip on using File::Basename to fixing the name of the script.

    -mox