Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Shell v Perl, here-doc as stdin

by dga (Hermit)
on Apr 11, 2003 at 16:03 UTC ( #249911=note: print w/replies, xml ) Need Help??

in reply to Shell v Perl, here-doc as stdin

I am not sure what you are asking exactly but here are a few possibilities.

As mentioned the here-document syntax is supported inside perl programs for data.

If you are wanting to send some input to 'system_command' then this could look really similar to a shell.

open FH, "|system_command"; print FH <<EOF EOF

The | in front of the command tells perl to send anything printed onto that filehandle along to the program. Also if you have a newer perl you can use the 3 element open and lexical filehandles so the open could look more like:

open my $fh, "|-", "system_command";

Of course, in perl, TIMTOWTDI, so you can also have a variable with content to be passed along.

open FH, "|system_command"; my $stuff="some things to pass along to system command\n"; print FH $stuff;

A perl script can be passed input via a here-doc from the shell just like any other command can recieve this data.

I hope one of these addresses the question that you had.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://249911]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2021-06-20 21:24 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (95 votes). Check out past polls.