Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

shared memory

by fionbarr (Friar)
on Mar 15, 2010 at 16:55 UTC ( [id://828727]=perlquestion: print w/replies, xml ) Need Help??

fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

hi I need to call a Perl program from a Perl program and capture the output (a string) from the 2nd program...I looked at IPC::Sharable but I can't install it on the CPU I'm using... Suggestions? (thanks)

Replies are listed 'Best First'.
Re: shared memory
by BrowserUk (Patriarch) on Mar 15, 2010 at 17:10 UTC

    What makes you think you need something complicated like IPC::Shareable to do this? (Or any other IPC::* module for that matter?)

    C:\test>type program.pl #! perl -slw use strict; print 'The string'; C:\test>perl -wE"say `perl program.pl`" The string

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      back-ticks seem to do it...thanks much!
Re: shared memory
by jfroebe (Parson) on Mar 15, 2010 at 17:04 UTC

    If you only need to read the output of the child process, take a look at IPC::Run3. It should meet your needs rather nicely from your description.

    Jason L. Froebe

    Blog, Tech Blog

Re: shared memory
by sundialsvc4 (Abbot) on Mar 15, 2010 at 23:17 UTC

    Fortunately for all of us, the designers of the Unix operating system realized that the notion of “solving problems by the combined efforts of many little programs” was a very potent way to solve a problem (even on a very small computer). So they made it very easy to do just that.

    The first brilliant simple idea they had was this:   Every program has a “standard input” (STDIN), “standard output” (STDOUT), and “standard error-output” (STDERR) file associated with it. “The output of” any program is automagically sent to “its STDOUT,” which defaults to the screen, and it accepts its input from “its STDIN,” which defaults to the keyboard. (It “pukes” to “its STDERR,” which also defaults to the screen.) Period. End of sentence. Every program works that way.

    The second brilliant idea follows from the first:   the STDOUT of one program can effortlessly be “piped into” the STDIN of the next program down the line. (Which can, of course, be “Perl itself.”) This makes it extremely easy to use the output of one program as the input to another ... no “magic incantations” required.

    Unix:   making amazingly complex things simple since 1969.

    (Windows, which has been “making simple things complicated” since somewhat-later, grudgingly followed suit. More or less.)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://828727]
Approved by jfroebe
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 15:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found