On Tue, 10 Sep 2013 16:42:37 +0200
Hugues Max <[email protected]> wrote:

> if I understand well, vars and  session can't be use outside of
> route,OK but  all rest of code can works correctly ?

Yeah - but code outside of route handlers / hooks will run at initial
startup.  That can be useful though, to set stuff up.  In the example
you gave, the global var you set can then be used within routes etc.

A few comments on your code:

> foreach my $fichier(@fichier) {
>          if ($fichier=~/\.xls$/i || $fichier=~/\.xlsx/i){
>                  my ($filename, $directory ) = fileparse($fichier);
>                  $fichierXls=$filename;
>          }
> }

You can match .xls/.xlsx in one regex with e.g.:

if ($fichier =~ /\.xlsx?$/i) {
    ...
}

You also missed anchoring to end of string in the second regex, so a
filename like fooxlsxfoo.jpg would match your check.

Also, you're going to look at every file you found and set $fichierXls
each time you find a spreadsheet file, so you'll end up with just the
filename of the last one found in $fichierXls.  It's not clear if
that's the desired behaviour or not.

Cheers

Dave P


-- 
David Precious ("bigpresh") <[email protected]>
http://www.preshweb.co.uk/     www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
www.preshweb.co.uk/cpan        www.preshweb.co.uk/github


_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to