using bash process substitution in perl pipe?

P

Peng Yu

I want to use bash instead of sh because I need the process
substitution. But by default perl use sh instead of bash. Is there a
way to let perl use bash?

#!/usr/bin/perl

use warnings;
use strict;

open(IN, 'ls <(echo main.txt) |');
foreach (<IN>) {
print
}
 
A

Alan Curry

I want to use bash instead of sh because I need the process
substitution. But by default perl use sh instead of bash. Is there a
way to let perl use bash?

#!/usr/bin/perl

use warnings;
use strict;

open(IN, 'ls <(echo main.txt) |');
foreach (<IN>) {
print
}

call bash -c 'your command' explicitly, like this:

open IN, '-|', $shell, '-c', $cmd

Where $shell is 'bash' or '/usr/bin/bash' or something else that names the
shell you want, and $cmd is the 'ls <(echo main.txt)' string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top