diff options
author | Yorhel <git@yorhel.nl> | 2020-12-25 16:48:30 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-12-25 16:48:30 +0100 |
commit | 9118ae3dc8feff69fecdf8a36f808ab245ab6002 (patch) | |
tree | dc28def1aafc30dca2205a1d73b59c04945d3378 | |
parent | 0a4f9dec767141b0e2e6f44365839a230f4aeaa4 (diff) |
Add tuwf->captures() convenience method
-rw-r--r-- | lib/TUWF.pm | 6 | ||||
-rw-r--r-- | lib/TUWF.pod | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/TUWF.pm b/lib/TUWF.pm index 6289f89..c082f72 100644 --- a/lib/TUWF.pm +++ b/lib/TUWF.pm @@ -517,6 +517,12 @@ sub capture { } +sub captures { + my $self = shift; + map $self->capture($_), @_; +} + + # writes a message to the log file. date, time and URL are automatically added our $_recursive_log = 0; sub log { diff --git a/lib/TUWF.pod b/lib/TUWF.pod index c1c5029..92173f6 100644 --- a/lib/TUWF.pod +++ b/lib/TUWF.pod @@ -669,6 +669,15 @@ named captures can be used, for example: Note that C<captures(0)> is not available; This would be equivalent to C<< tuwf->reqPath >>, save for the leading slash. +=head2 captures(@keys) + +Multiple-argument version of C<capture()>, returns the a list of values +associated with the given keys. Example: + + TUWF::get qr{/user/([0-9]+)/file/(.+)} => sub { + my($user_id, $file) = tuwf->captures(1,2); + }; + =head2 debug() Returns the value of the I<debug> setting. |