3 ms·
You might like Perl. The syntax to invoke and interact with processes is much more terse than Python's. And there's quite a lot of history of using it instead o
by tyingq 6y ago
You might like Perl. The syntax to invoke and interact with processes is much more terse than Python's. And there's quite a lot of history of using it instead of shell scripts.
Edit: Things like:
$output=`ls`;
$output=qx#ls -l#;
system('/bin/echo','avoid','subshell','invocation');
open("APIPELINE","ls -l |");
while (<APIPELINE>) {
chomp;
print "Got line: [$_]\n";
}
close(APIPELINE);
And access to child exit status in a way that's familiar ($?), etc.
- dale_glass 6y agoThat Perl is quite out of date. These days, Perl has 3 argument open, and can use a variable for a filehandle. So: open(my $pipeline, "-|", "ls -l"); This is a good thing, because you can treat a filehandle as a standard variable, and can separate the special stuff from the command itself. This way if you're taking in user input, they don't get to mess with that. You can also do: open(my $pipeline, "-|", "ls", "-l", $directory); Which lets you get away from the mess of correct quoting and just pass every parameter exactly as intended.