in reply to how to remove everything before last slash in perl?

Another option you have is the built-in module File::Spec.

Here's a script that shows how you might use it. Things to note (details in the doco):

#!/usr/bin/env perl use 5.010; use strict; use warnings; use File::Spec; my $no_file = 1; while (my $path = <DATA>) { chomp $path; my ($volume, $directories, $file) = File::Spec->splitpath($path, $no_file); my @dirs = grep { length } File::Spec->splitdir($directories); my $last_dir = $dirs[-1]; say qq{$path }, q{.} x (24 - length($last_dir) - $path =~ m{\W$}), qq{ $last_dir}; } __DATA__ y:/home/lib/directory/book y:/home/lib/directory/book_manager y:/home/lib/directory/piano_book y:/home/lib/directory/with_trailing_slash/

Output:

$ pm_after_slash.pl y:/home/lib/directory/book .................... book y:/home/lib/directory/book_manager ............ book_manager y:/home/lib/directory/piano_book .............. piano_book y:/home/lib/directory/with_trailing_slash/ .... with_trailing_slash

-- Ken