Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: $var | system()

by kennethk (Abbot)
on Sep 05, 2012 at 16:34 UTC ( #991888=note: print w/ replies, xml ) Need Help??


in reply to $var | system()

If by "multiline text" you mean feed it input via STDIN, you can explicitly open a pipe using open, e.g.

open my $stream, "| mail -s '123' email\@at.com" or die "pipe fail: $! +"; print $stream $text; # Or @lines, or $line1, $line2... close $stream; # Handle needs to close or go out of scope to clear buf +fer and send EOF

There are a large number of other possibilities here, depending on how complex you want to get: system; pipe, fork and exec; IPC::Open2; IPC::Open3... See perlipc for some gory detail.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


Comment on Re: $var | system()
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (12)
As of 2015-07-07 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls