[Dancer-users] Generating PDF with Template-Plugin-Latex fails inside route handler

Alastair Sherringham sherringham at gmail.com
Sat Jan 8 16:32:00 CET 2011


Mike,

The docs for "system" e.g.

http://perldoc.perl.org/functions/system.html

talk about the return code - and how to interpret it. I've had a play
with Dancer using the code as per perldoc "system" - see below. Not
sure what the issue is.

1) Run via dancer built in server :

perl bin/app.pl

http://localhost:3000 shows :

Got : [failed to execute: No child processes]

2) Run via plackup :

plackup -p 3000 bin/app.pl

http://localhost:3000 shows :

Got : [child exited with value 0]

I expect (2) - and it is what I get on the command line (with the
subroutine run_cmd()). Something is different with running via the
dancer server - not sure what.

Code :

#-----------------------------------------------------------------------------------
package TestApp;
use Dancer ':syntax';

our $VERSION = '0.1';

get '/' => sub {
    my $o = run_cmd();
    return "<p>Got : [$o]</p>";

};

sub run_cmd
{
    my ($return,$msg);
    system("/usr/local/bin/hg","--version");
    $return = $?;

    if ($? == -1) {
        $msg = "failed to execute: $!";
    }
    elsif ($? & 127) {
        $msg = sprintf("child died with signal %d, %s coredump",
            ($? & 127), ($? & 128) ? 'with' : 'without');
    }
    else {
        $msg = sprintf("child exited with value %d", $? >> 8);
    }
    return $msg;
}

true;
#------------------------------------------------------------------

Cheers,
Alastair


On 7 January 2011 23:38, Mike Mandel <mandel at stud.fh-hannover.de> wrote:
> Hello,
>
> I tracked it down a little bit, and found out, that the return code
> of the system() function is different inside a route handler than outside.
> Could please someone test this?

-- 
Alastair Sherringham
http://www.sherringham.net


More information about the Dancer-users mailing list