I'm building a webapp using dancer2 as backend tool. I've implemented the main method as follow:
#!/usr/bin/env perl
use Dancer2;
get '/mything/:text' => sub {
my @myArray = ("");
# Fill the array with DB data;
return join "<br>", @myArray;
};
dance;
Everything is fine until the second time get method is used. Insted of @myArray
being empty, its filled with the from the first execution.
As a dirty fix, I initialize @myArray
to ("")
at the end of the method, but I think that is ugly. Have you any experience on this?
Problem was related to not using perl in strict mode. The code as it was, was working properly in OSX 11.1 but not in Ubuntu 16.04. So after some tests, I found that some variables that I use to fill the array from the DB weren't properly initialized. After initialize them, everything is working as it should in OSX and Ubuntu.