#!/usr/bin/perl use strict; my $long_file = '/abc/xyz/abc.txt'; my $file = ( split( "/", $long_file ) )[-1]; print "$file\n";