in reply to I humbly ask for your help with parsing

$_ = '/usr/local/www/someth/file.cfg'; print "$1\n" if /.+\/(\w+)\//;
no?

Replies are listed 'Best First'.
Re^2: I humbly ask for your help with parsing
by marinersk (Priest) on Oct 31, 2013 at 00:17 UTC
    The main benefit of matured modules is they handle corner cases you might have overlooked. Your code would, I agree, work most of the time, but if you get an odd directory name with a slash in it, she fails:

    $_ = '/usr/local/www/"something/other"/"This file/data thing.cfg"'; print "$1\n" if /.+\/(\w+)\//; www
      I agree, it's just,
      if the author's task is to thrash through some ordinary-named directories
      maybe he doesn't need all this module-stuff.
        Excellent point.

        So long as the OP also understands the potential risks, an informed decision can be made.

        I personally tend to over-engineer everything; I am convinced that I am the butt of the old joke about "sometimes you have to fire the engineer and ship the product".

        Sometimes the quick solution is sufficiently effective and, I begrudgingly admit, the better choice in far more circumstances than my instincts would have me believe.