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

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -