0

In the mojolite script for MojoExample, there are the lines below, I want to know what does "=>" mean in "blogstagtags => tags => 'perlsonal'". I think "=>" is delimiter between hash key and value. Can I find the explanation anywhere?

get '/blogs' => sub {
    shift->redirect_to(blogstagtags => tags => 'personal'); # Where is blogstagtags defined? #yaohe
    # blogstagtags is the route name for 'blogs/tag/(*tags)' by default #yaohe
};

get '/blogs/tag/(*tags)' => sub {
    my $self = shift;
    # Specified tags to search for: /tag/one/tag/two/tag/three
    my @tags = grep $_ ne 'tag' => split '/' => $self->param('tags');

    my @blogs = $self->db->resultset('Blog')->by_tags(@tags) or return $self->redirect_to('blogs');

    $self->render('blogs/index', blogs => [@blogs],);
};
He Yao
  • 1
  • 1

2 Answers2

0
blogstagtags => tags => 'personal' 

is the same as

blogstagtags => (tags=>'personal')

Now I can answer this question myself. This is a Perl syntax question, not of mojolicious. The hash (tags=>'personal') is passed to the argument 'blogstagtags'.

He Yao
  • 1
  • 1
0

that operator is only "syntactical sugar" basically works as the comma , expect for extra allowance of the use of "bare word" on the left

see https://stackoverflow.com/a/4093914/1681985

arhak
  • 2,488
  • 1
  • 24
  • 38