use strict; use warnings; my ($path, $file); while (<DATA>) { chomp; ($path, $file) = splitPath($_); print "My path is $path\n"; print "My file is $file\n\n"; } sub splitPath { if ($_[0] =~ m|(.*/)(.*)|) { return ($1, $2); } return ('', $_[0]); } __DATA__ a/b/c/filename1.someext b/c/filename2.sh d/e/f/g/filename3.exe filename.txt
In reply to Re: split a path/filename
by TJPride
in thread split a path/filename
by akrrs7
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |