[dancer-users] get session info without route
Hugues Max
huguesmax at gmail.com
Tue Sep 10 16:38:02 BST 2013
Thanks david
if ($fichier =~ /\.xlsx?$/i)
is better
yes this is ambiguous code , I search all xls(x) files in directory ,
but I will take only one
bye
Hugues.
Le 10/09/2013 17:04, David Precious a écrit :
> On Tue, 10 Sep 2013 16:42:37 +0200
> Hugues Max <huguesmax at gmail.com> 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
>
>
More information about the dancer-users
mailing list