Farabi
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
eg/run_system_cmd.pl view on Meta::CPAN
use Modern::Perl;
use Mojolicious::Lite;
use System::Command;
use Mojo::IOLoop;
use Mojo::Util qw(xml_escape);
my %results;
get '/' => sub {
my $self = shift;
my $html;
if ( scalar keys %results > 0 ) {
$html = '<pre>Process table:<table border="1">';
for my $result ( values %results ) {
my $stdout = substr $result->{stdout},0,50;
my $stderr = substr $result->{stderr},0,50;
$stdout = xml_escape($stdout);
$stderr = xml_escape($stderr);
$html .=
'<tr><td>'
. $result->{pid}
. '</td><td>'
. $result->{cmd}
. '</td><td>'
. $result->{status}
. '</td><td>'
. $stdout
. '</td><td>'
. $stderr
. '</td></tr>';
}
$html .= '</table></pre>';
}
else {
$html = 'Empty!';
}
$self->render( text => <<HTML);
Hello
<form action="/start">
<input type="submit" value="Run!"></input>
</form>
$html
HTML
};
get '/start' => sub {
my $self = shift;
# invoke an external command, and return an object
my $cmd;
my $timer;
#my @cmds = ('ack', '--nopager', '--nobreak', '--noenv', 'abc');
#my @cmds = ('ack', '--nofilter', '.');
#my @cmds = ( 'ack', '--nofilter1', 'Hello' );
my @cmds = ( 'ack', '--nofilter', '.' );
#my @cmds = ( 'perl', 'hello_world.pl' );
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.526 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )