BladeSystem Forums have moved here
To make BladeSystem information easier to find, we have moved the BladeSystem forums here, to Servers and Operating Systems.
Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

can PERL handle multiple pipes on 1 line?

SOLVED
Go to Solution
Honored Contributor

can PERL handle multiple pipes on 1 line?

Hi all:

Using perl 5.8.3 on a HPUX 11.00.

I have a perl script for helpdesk to assista in management of printers.

A new option, search all printers for a pattern
Easy enough, use grep.

elsif ($choice eq '8') {
print "Search a specific print queue - what is partial printer name? ";
$prt = ;
system "/usr/bin/lpstat -t \| grep -i $prt";
&TheMenu;
}

But if I want to add another pipe to 'more', it gives me a syntax error.

system "/usr/bin/lpstat -t \| grep -i $prt | more";


There could be hundreds of printers matching the pattern so I need to page the output. But how do I pipe to more with the above command?
2 REPLIES
Acclaimed Contributor

Re: can PERL handle multiple pipes on 1 line?

Yes, in this case the system call is simply passed to the shell. The confusion is caused by a LF in stdin.

I'll bet this works:
$prt = "xxx";
system("lpstat -t | grep -i $prt | more")

however your example fails.

after your:
$prt = ;
add this line:
chomp($prt);
I think that will fix you.

I also notice that you escaped one of your pipe symbols but not the other; you shouldn't need an escape.
If it ain't broke, I can fix that.
Honored Contributor

Re: can PERL handle multiple pipes on 1 line?

Hi Clay:

Both ways work. Many thanks.