- or download this
# WARNING: THIS CODE HAS A SECURITY HOLE
print "Which file to show? ";
...
die "bad filename" if $f=~/\.\./; # don't allow updirs
system("cat /sharedfiles/$f")==0
or die "command failed, \$?=$?";
- or download this
system("cat", "/sharedfiles/$f")==0
or die "command failed, \$?=$?";
# OR
system({"cat"} "cat", "/sharedfiles/$f")==0
or die "command failed, \$?=$?";
- or download this
use IPC::Run3 0.047 'run3';
my $cmd = ['cat','-nE'];
...
die "run3 failed, \$?=$?" unless $?==0;
print "# STDOUT:\n$stdout";
print "# STDERR:\n$stderr";
- or download this
use Capture::Tiny 'capture';
my ($stdout, $stderr, $exit) = capture {
...
die "system failed, \$?=$exit" unless $exit==0;
print "# STDOUT:\n$stdout";
print "# STDERR:\n$stderr";
- or download this
use IPC::System::Simple qw/systemx capturex/;
print "# systemx:\n";
systemx 'echo', 'Hello,', 'World!';
my $stdout = capturex 'echo', 'Hello,', 'World!';
print "# capturex: $stdout";
- or download this
$ cat lengthsum.pl
#!/usr/bin/env perl
...
$ cat /usr/share/dict/words | ./lengthsum.pl
839677
- or download this
use 5.008;
my @cmd = ('cat', '/usr/share/dict/words');
...
}
close $fh or die $! ? $! : $?;
print "$sum\n";
- or download this
use IPC::Run qw/ run new_chunker /;
...
$sum+=length $line;
} or die $?;
print "$sum\n";