adding a backticks test in addition to system()
[catagits/Catalyst-Runtime.git] / t / lib / TestApp / Controller / Fork.pm
1 #!/usr/bin/perl
2 # Fork.pm 
3 # Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org>
4
5 package TestApp::Controller::Fork;
6
7 use strict;
8 use warnings;
9 use base 'Catalyst::Controller';
10 use YAML;
11
12 sub fork : Local {
13     my ($self, $c, $ls) = @_;
14     my ($result, $code) = (undef, 1);
15
16     if(!-e $ls || !-x _){ 
17         $result = 'skip';
18         $code = 0;
19     }
20     else {
21         $result = system($ls, $ls, $ls) || $!;
22         $code = $?;
23     }
24     
25     $c->response->body(Dump({result => $result, code => $code}));
26 }
27
28 sub backticks : Local {
29     my ($self, $c, $ls) = @_;
30     my ($result, $code) = (undef, 1);
31     
32     if(!-e $ls || !-x _){ 
33         $result = 'skip';
34         $code = 0;
35     }
36     else {
37         $result = `$ls $ls $ls` || $!;
38         $code = $?;
39     }
40     
41     $c->response->body(Dump({result => $result, code => $code}));
42 }
43   
44 1;