Welcome to WebmasterWorld Guest from 184.73.126.70

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

referring to standard input in a unix pipeline

passing output from perl script between unix scripts

   
10:28 pm on Mar 29, 2006 (gmt 0)

10+ Year Member



hey everyone,

I have the following question.

I have a unix script script1 which invokes a perl script and gets some output from it. The perl script has one print statement at the end which sends the data to stdout

Code:

print STDOUT $log;

my unix pipeline looks like this:

Code:

script 1 ¦ script 2

how can script 2 refer to the output from script 1 (which is output from a perl script) .. is it with $1? or is that just command line variables?

any help appreciated,
Alex ...

1:45 pm on Mar 30, 2006 (gmt 0)

10+ Year Member



[perl]
while (my $line = <STDIN>) {
$line =~ s/a/b/;
print $line;
}
[/perl]

or, for the uber-efficient, $_ is implied pretty much everywhere -

[perl]
while (<STDIN>) {
s/a/b/;
print;
}
[/perl]

12:01 am on Mar 31, 2006 (gmt 0)

10+ Year Member



worked fine, thanks!