Suppose I have a path in a string called \'/home/user/directory/HelloWorld.txt\'. I would like to remove the HelloWorld.txt, and end up with \'/home/user/directory\'. What rege
split on "/", remove last element and join them back.
$path='/home/user/directory/HelloWorld.txt'; @s = split /\// ,$path; pop(@s); print join("/",@s);