You can read the input from the STDIN filehandle.
[Perl script]
#!/usr/bin/perl
my $linecount = 0;
while ( my $line = <STDIN> ) {
$linecount++;
print "Line $linecount: $line";
}
[At the command line...]
# this cats the file, and the script adds numbers
# to each line before printing them out.
cat somefile | ./myscript.pl
# printed data can be piped to another file...
# this cats the file, the script then adds line
# numbers, then this is piped to wc to get a
# line count... so the only output is the number
# of lines counted by wc.
cat somefile | ./myscript.pl | wc -l
Rob
-----Original Message-----
From: Mariana A�ez [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 28, 2001 2:21 PM
To: [EMAIL PROTECTED]
Subject: Pipes
Hi
How can i do a pipe program with perl?
I mean I want to make a program it can be used like this:
> ls | myprogram | ps
Is using "open" the only way?
Thanks in advance and HAPPY HOLIDAYS!!!!
Mariana C. A�ez Salaverria
---------------------------------------
Sync Consultores c.a.
www.sync.com.ve
Av. Libertador, Torre Maracaibo Of 13H
Caracas - Venezuela
Telf.: (0212) 762-8555/3012/8693
Fax : (0212) 762-6671
Cel : (0416) 622-0000
--------------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]