Welcome to WebmasterWorld Guest from 54.167.46.29

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)

Junior Member

10+ Year Member

joined:Feb 1, 2004
posts:179
votes: 0


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)

Preferred Member

10+ Year Member

joined:Dec 30, 2003
posts:428
votes: 0


[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)

Junior Member

10+ Year Member

joined:Feb 1, 2004
posts:179
votes: 0


worked fine, thanks!