I installed Dancer2, placked up it and opened web page from localhost.
Everything is OK until here.
There is following info at manual:
The code block given to the route handler has to return a string which will be used as the content to render to the client.
It is clear for following example
get '/test1/:name' => sub {
return "Hi there " . params->{name};
};
because it returns a string and when I write
http://localhost:5000/test1/kadir to browser I see
Hi there kadir which is the string I expect to see
But next example is as follow:
get '/test2/:name' => sub {
"Hey ".param('name').", welcome here!";
};
It does not return anything. Because there is no return keyword.
But above red background colored sentence says that it must return a value?
Next example is stranger:
get '/test3/:name' => sub {
"Hello there, " . defined param('name')
? param('name')
: "whoever you are!";
};
Again there is no
return keyword. When I write
http://localhost:5000/test3/kadir I see only kadir. But at test2 example, I saw all words despite there is no return keyword. So what is rule?
-- Kadir Beyazlı
Computer Engineer
GSM : +90 535 821 50 00