Perl v5.18.2 on Fedora 20
Uses modules. If these are not installed on your system see the article on installing cpan modules.
#!/usr/bin/perl
# This program prints the current directory path
# and the last directory name (in the path) to the screen
use strict;
use warnings;
use Cwd;
use File::Basename;
# Create variables using the cpan modules
my $dirpath = getcwd;
my $dirname = basename(getcwd);
# print the results to the screen
print "$dirpath\n";
print "$dirname\n";