in reply to Return value from a binding operator?
Hi Chris,
Think of the middle match as a substition.
the match basically looks to match all of the string after the last / character. The end of line anchor $ is included in the capturing group, where we may be used to seeing this outside of the capturing group.
It does not so much as as strip the path off, rather matches the final part of the path, or the basename. I don't know if including the eol anchor $ retrieves the eol character or makes no difference.
m! #start match /? # 0 or 1 '/' ( # start capture $1 [^/] #consisting of no '/' characters + # 1 or more times $ # until and including eol (?) ) # end capture $1 ! # end match
this would also match a path with no directories.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Return value from a binding operator?
by Spinone (Novice) on Apr 12, 2013 at 23:07 UTC | |
by dsheroh (Monsignor) on Apr 13, 2013 at 09:50 UTC |
In Section
Seekers of Perl Wisdom