...
Code Block | ||||
---|---|---|---|---|
| ||||
use Carp;
my $dir = $ARGV[0];
open( my $listing, "-|", "ls -F $dir") or croak "error executing command: stopped";
while (<$listing>) {
print "Result: $_";
}
close( $listing);
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
use Carp;
my $file;
my $dir = $ARGV[0];
croak "Argument contains unsanitary characters, stopped" if ($dir =~ m|[^-A-Za-z0-9_/.~]|);
open( my $listing, "-|", "ls -F $dir") or croak "error executing command: stopped";
while (<$listing>) {
print "Result: $_";
}
close( $listing);
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
use Carp;
my %choices = (BIN => "~/bin",
LIB => "~/lib",
SRC => "~/src");
my $choice = $choices{$ARGV[0]};
croak "Invalid argument, stopped" if (!defined $choice);
open( my $listing, "-|", "ls -F $choice") or croak "error executing command: stopped";
while (<$listing>) {
print "Result: $_";
}
close( $listing);
|
...