Get the basename of a file : File « System Functions « Perl






Get the basename of a file

     

    #!/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 basename of the given filename.
    my $base = basename($filename, "");
    print "The basename of $filename is $base\n";

   
    
    
    
    
  








Related examples in the same category

1.use File::Compare to compare two files
2.Get the dirname from a file name