[Dancer-users] Problem with an open filehandler within the route

Thomas Maier hayzer at gmail.com
Tue Feb 15 14:22:59 CET 2011


Hi,
I have the follow route:
{{{

get qr{/(tests/.*)} => sub {
     my ($filename) = splat;
     my $testdata = {};
     open my $stdout, "-|", "cli","--flag",$filename;
     while(<$stdout>) {
         my ($id,$name) = split/:/,$_;
         $testdata->{$id} = qq{$name};
     }
     template 'show_test_case', {
         filename => $filename,
         testdata => $testdata,
     };
};

}}}

Following the route (/tests/something) for the first time gives the
expected results, meaning the list of $id's and $name's.
But when executing the route for the second time, it shows the follow
runtime error:
"
Warning caught during route execution: readline() on closed filehandle 
$stdout
"

Is there some limitation for working with filehandlers withing the route
subroutine?

Thomas


More information about the Dancer-users mailing list