S
seth
My question is about pips.
I have the following code:
EXAMPLE 1:
#-----------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $command = "ls -al";
my @failureMsg;
open(OUTPUT, "$command |") or die "can't do the command\n";
my $lines = <OUTPUT>;
@failureMsg = grep(/\ssp.*\.pl$/, <OUTPUT>);
print "@failureMsg";
#-----------------------------------------------------------
In this code I'm piping my the output of my command to a file
handle(FH).
I understand this and am happy with it.
What I don't understand is the following syntax:
EXAMPLE 2:
open(OUTPUT, " | $command") or die "can't do the command\n";
**note: the example of what I don't understand has no realtion to my
code snippet above. My example 2 might not be ideal.. but here is what
I don't undestand.
Example 1 shows how to "pipe" *into* a FileHandle.
So is doing something like Example 2 piping *from* a FileHandle?
Can someone point me to a quick simple example. I've checked most of
the Orielly series and can't find an example to help me understand what
the meaning is for prepnding "$command" with the pipe char.
-thanks
seth
I have the following code:
EXAMPLE 1:
#-----------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $command = "ls -al";
my @failureMsg;
open(OUTPUT, "$command |") or die "can't do the command\n";
my $lines = <OUTPUT>;
@failureMsg = grep(/\ssp.*\.pl$/, <OUTPUT>);
print "@failureMsg";
#-----------------------------------------------------------
In this code I'm piping my the output of my command to a file
handle(FH).
I understand this and am happy with it.
What I don't understand is the following syntax:
EXAMPLE 2:
open(OUTPUT, " | $command") or die "can't do the command\n";
**note: the example of what I don't understand has no realtion to my
code snippet above. My example 2 might not be ideal.. but here is what
I don't undestand.
Example 1 shows how to "pipe" *into* a FileHandle.
So is doing something like Example 2 piping *from* a FileHandle?
Can someone point me to a quick simple example. I've checked most of
the Orielly series and can't find an example to help me understand what
the meaning is for prepnding "$command" with the pipe char.
-thanks
seth