Extracts base file name from full path. Uses DOS/Windows conventions. : fileparse « File « Perl






Extracts base file name from full path. Uses DOS/Windows conventions.

    

#use File::Basename;
#fileparse_set_fstype("MSDOS");

#The other supported types are AmigaOS, os2, MSWin32, VMS, MacOS, and RISCOS. 
#UNIX is the default type.

#!/usr/bin/perl -w
use File::Basename;

fileparse_set_fstype("MSDOS");

$fullname = 'C:\Perl\lib\site\validate.pl';

@suffixlist = '.pl';

($basename, $directory_path, $suffix) = fileparse($fullname, @suffixlist);

print "For   $fullname\n";
print "base: $basename\n";
print "path: $directory_path\n";
print "ext.: $suffix\n";

          

   
    
    
    
  








Related examples in the same category