in reply to Regular Expression Help

Interesting, I think 'split' when I see something separated by slashes. Off the top of my head, the below code will do what you are looking for:
my @dirs = qw ( /usr/local/bin/ /var/tmp/somefile / /home/foo/bar ); foreach ( @dirs ) { my @dir; my $lastdir; if ( /^\/$/ ) { $lastdir = "/"; print "$lastdir\n"; next; } if ( /\/$/ ) { chop; } @dir = split('/'); $lastdir = pop(@dir); print "$lastdir\n"; }
Will print:

bin
somefile
/
bar

Sorry if this is hacky code. I'm a Monks newb and have made my career by pounding out this type of randomness.