Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between :Args and :CaptureArgs in Catalyst?

Tags:

perl

catalyst

I can usually get the behavior I desire by just randomly trying different permutations of these two options, but I still can't say I know precisely what they do. Is there a concrete example that demonstrates the difference?

like image 363
friedo Avatar asked Jun 20 '12 00:06

friedo


1 Answers

:CaptureArgs(N) matches if there are at least N args left. It is used for non-terminal Chained handlers.

:Args(N) only matches if there are exactly N args left.

For example,

sub catalog : Chained : CaptureArgs(1) {
    my ( $self, $c, $arg ) = @_;
    ...
}

sub item : Chained('catalog') : Args(2) {
    my ( $self, $c, $arg1, $arg2 ) = @_;
    ...
}

matches

/catalog/*/item/*/*
like image 175
ikegami Avatar answered Oct 02 '22 04:10

ikegami