in reply to removing the last word

Yes, you can use regexs like:
my $full = '/usr/local/jboss'; my ($dir, $file) = $full =~ m|(.+)/(.+)|;
But it is better to use core module if such one exists - File::Basename in this case. Thus you will not make mistake while reinventing the wheel.