use File::Spec::Functions qw( rel2abs splitpath ); print +( splitpath rel2abs $0 )[2];