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

sawyer x xsawyerx at gmail.com
Tue Feb 15 15:41:25 CET 2011


That's odd. The routes are just saved and rerun every time, but they're
enclosed scopes so that shouldn't happen.
I'm probably too tired and not smart enough to clearly see something simple
that's happening here.

My suggestion is: close the damn filehandle when you're done with it! :)

Sawyer.

On Tue, Feb 15, 2011 at 3: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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20110215/d9cdd6d4/attachment.htm>


More information about the Dancer-users mailing list