#!/usr/bin/perl

use strict;
use warnings;
use File::Basename;

my $fullpath='YourFileFullpath'; my ($name, $path,$suffix) = fileparse($fullpath); print "name=$name\n";
print "path=$path\n"; print "suffix=$suffix\n";

# On Unix
$fullpath="/foo/bar/baz"; # returns$name="baz", $path="/foo/bar/", suffix=""; # On Windows$fullpath='C:\foo\bar\baz';
# returns
$name="baz",$path='C:\foo\bar\', suffix="";

# get file name, It does NOT always return the file name portion of a path as you might expect. To be safe, if you want the file name portion of a path use fileparse() .
$fullpath="/foo/bar/baz"; my$name = basename($fullpath); #return$name="baz"