[Dancer-users] Problem with an open filehandler within the route
Flavio Poletti
polettix at gmail.com
Tue Feb 15 16:02:40 CET 2011
You are not checking whether the open() is successful or not (unless
you're using autodie or Fatal, which is not shown here). I suspect
this might have something to do with your error.
Cheers,
Flavio.
On Tue, Feb 15, 2011 at 2:22 PM, Thomas Maier <hayzer at gmail.com> wrote:
> 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
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
More information about the Dancer-users
mailing list