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

javascript - THREE.js reposition vertices for RingGeometry -

javascript - I need to update the text of a paragraph by inline edit -

assembly - What is the addressing mode for ld, add, and rjmp instructions? -