[ back to toc ]

Perl vs. ksh

Date: 2002/05/02 10:19

Can you use the pipe command in Perl like you can in Korn Shell.... ls |
wc ?

I am used to doing something like this in ksh
and would like to do it in perl ...

result='"select * from table;" | sqlplus $user/$pass'

So I assign results of query to variable result.

Any help would be appreciated.
The pipe joins two processes io wise. If you start a new process in Perl,
you can bind Perl file pipes to the input and the output of the new
process. To get knowledge how to do this you should read the documentation
of the command/function 'popen'. See 'man perlfunc'.

On the second thought I am almost certain that you need something
different. You get used to ksh programming and Perl programming needs
different type of thinking. When you write

result='"select * from table;" | sqlplus $user/$pass'

in ksh you could do in Perl

$dbh = DBI-open($db,$user,$pass);
$dbh->query("select * from table");

I recommend that you rethink what you really need.


[ back to toc ]