From: Matt S Trout Date: Fri, 27 Apr 2012 02:28:59 +0000 (+0000) Subject: brief docs for path matches X-Git-Tag: v0.014~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=7c03cd612110f7b5d84ae20100bc13ce58d36050 brief docs for path matches --- diff --git a/lib/Web/Simple.pm b/lib/Web/Simple.pm index c925bda..47d7a0e 100644 --- a/lib/Web/Simple.pm +++ b/lib/Web/Simple.pm @@ -398,6 +398,26 @@ subdispatchers to scope common activities. For example: You should note the special case path match C which is only meaningful when it is contained in this type of path match. It matches to an empty path. +=head4 Naming your patch matches + +Any */**/*.*/**.* match can be followed with :name to make it into a named +match, so: + + sub (/*:one/*:two/*:three/*:four) { + "I match /1/2/3/4 capturing { one => 1, two => 2, three => 3, four => 4 }" + } + + sub (/**.*:allofit) { + "I match anything capturing { allofit => \$whole_path }" + } + +In the specific case of a simple single-* match, the * may be omitted, to +allow you to write: + + sub (/:one/:two/:three/:four) { + "I match /1/2/3/4 capturing { one => 1, two => 2, three => 3, four => 4 }" + } + =head4 C and C are different specs As you may have noticed with the difference between C and