programming-examples/perl/SystemFunction/Get the dirname from a file name.pl
2019-11-15 12:59:38 +01:00

11 lines
335 B
Perl

#!/usr/local/bin/perl -w
use File::Basename;
use Getopt::Long;
my $ret = GetOptions ("f|filename:s");
my $filename = $opt_f || die "Usage: $0 -f filename\n";
# Return the dirname of the given filename.
my $dirname = dirname($filename);
print "The directory name of $filename is $dirname\n";