[dancer-users] route handler for a URL that matches a token

Andrew Solomon andrew at geekuni.com
Thu Sep 17 17:46:21 BST 2015


Hi Richard

Just to expand on what Kadir said. This

my $hashref = {
           $incoming_token = params->{token},          # LINE 554
};

is equivalent to

my $incoming_token = params->{token};
my $hashref = { $incoming_token };

which is incorrect since a hash is constructed of a sequence of key-value
pairs, and hence the complaint that you have an odd number of elements in
the hash.

Andrew


On Thu, Sep 17, 2015 at 5:22 PM, Kadir Beyazlı <kadirbeyazli at gmail.com>
wrote:

>
> 17 Eyl 2015 18:31 tarihinde "Richard Reina" <gatorreina at gmail.com> yazdı:
> >
> > 2015-09-17 9:06 GMT-05:00 Andrew Solomon <andrew at geekuni.com>:
> >>
> >> That looks reasonably sane to me apart from:
> >>   my $input_hash {
> >>
> >>     token => params->{token}
> >>
> >>     }
> >>
> >> which should be
> >>   my $input_hash =  {
> >>
> >>     token => params->{token}
> >>
> >>     };
> >>
> >>
> > Hi Andrew,
> >
> > That piece of code is the part that is giving me trouble.
> >
> > I have switched to using a scalar as since there is only one element
> that I seek to capture (the usrl/token) and because using a hash wasn't
> working either.
> >
> > Here is where I am:
> >
> >  get '/reset/:token' => sub {
> >
> >     my $incoming_token;
> >
> >     return template 'passreset' => {
> >
> >           $incoming_token = params->{token},          # LINE 554
> >
> >     };
> You dont need define variable here. Also you should use "=>" instead of
> "=" as follow.
>
> incoming_token => params->{token}
>
> >
> >     # get stored tokens to match against $incoming_token
> >     my ($matched_user_id) = User->lookup_tokens($input_hash->{token});
> >
> > But the it fails and the input at the console says:
> >
> > [MyApp:25074] core @2015-09-17 10:21:52> Entering hook
> core.app.before_request in (eval 77) l. 1
> > Odd number of elements in anonymous hash at
> /home/richard/Dancer2/MyApp/bin/../lib/MyApp.pm line 554.
> >
> > I am just trying to capture the value of the url so I can test if it
> matches the stored token.  Help would be greeeaaaaaaatly appreciated as
> this s very frustrating.
> >
> > Thanks
> >
> > _______________________________________________
> > dancer-users mailing list
> > dancer-users at dancer.pm
> > http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
> >
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>


-- 
Andrew Solomon

Mentor at Geekuni http://geekuni.com/
http://www.linkedin.com/in/asolomon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150917/9c92c97c/attachment.html>


More information about the dancer-users mailing list