[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Catalyst Action @args tip



FYI,

 

Catalyst parses URL arguments for you. So if someone hits the URL "/histPhoenix/blah" you can say

 

sub histPhoenix : Local {

   my ($self, $c, @args) = @_;

 

and $args[0] will be 'blah'.

 

 

 

So instead of writing this:

 

sub histPhoenix : Local {

   my ($self, $c) = @_;

   my $uri=${$c->req->uri};

   if ( my ($type)=( $uri =~ /histPhoenix\/(.+?)$/i ) ) {

 

 

You can just do this:

 

sub histPhoenix : Local {

   my ($self, $c, $type) = @_;

 

 

$0.02,

 

j