Get filepath from filelocation using Perl and Regex -
Get filepath from filelocation using Perl and Regex -
suppose have a
$path = "/usr/local/bin/mybinary"
how can utilize regular expressions $regex = "/usr/local/bin"
.
i new regex. tried follows:
$regex =~ s/w+/.*\//
this doesnt work. how can want?
using regex:
$path = "/usr/local/bin/mybinary" $parent = $path =~ m{(.*)/} ? $1 : warn "unrecognized";
however, recommend using file::basename
or similar module:
use file::basename; $dir = dirname($path);
regex perl
Comments
Post a Comment