Are you after "dirname", past of File::Basename? http://perldoc.perl.org/File/Basename.html
$ perl -MFile::Basename -le 'print dirname(shift)' /path/to/some/directory/somewhere /path/to/some/directory Duncs -----Original Message----- From: fluca1...@gmail.com [mailto:fluca1...@gmail.com] On Behalf Of Luca Ferrari Sent: 27 November 2017 09:55 To: beginners@perl.org Subject: is there a way to shorten these lines? Hi all, I cannot figure how but I think it is possible to reduce the following to a nested single stamente: my @remote_dirs = File::Spec->splitdir( $remote_path ); pop @remote_dirs; $remote_path = File::Spec->catdir( @remote_dirs ); The idea is to remove from a path the last directory and rebuild the path itself. Since this is executed due to a particular condition, I would like to express it as a postponed if but I cannot find a short way of doing it. Any idea? Thanks, Luca -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/