3 ms·
That 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"); Thi
by dale_glass 6y ago
That 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.