# Remove the file path information, if needed if ( $file =~ /([^\/\\]+)$/ ) { $filename = $1; # Set the filename } else { $filename = $file; }