Hi, I am new to open3 and perldoc is too vague to understand I am trying a simple perforce command to run in open3.Basically I want to capture both STDOUT and STDERR aswell.I have tried various ways but none of them seem to be working.I am hoping someone will comment.

foreach my $file (@changed_files) { #my $p4where_output=`p4 where $file > NUL: 2>&1`;#backticks option not + working,so commented out #print "P4 where output:$p4where_output\n"; my $cmd = "p4 where $file"; local(*HIS_IN, *HIS_OUT, *HIS_ERR); my $childpid = open3(*HIS_IN, *HIS_OUT, *HIS_ERR, p4 where $cmd); print HIS_IN "stuff\n"; close(HIS_IN); # Give end of file to kid. my @outlines = <HIS_OUT>; # Read till EOF. my @errlines = <HIS_ERR>; # XXX: block potential if massive print "STDOUT:\n", @outlines, "\n"; print "STDERR:\n", @errlines, "\n"; print @errlines; close HIS_OUT; close HIS_ERR; waitpid($childpid, 0); if ($?) { print "That child exited with wait status of $?\n"; } if(@errlines eq 'file(s) not in client view') { push @changed_paths,"$file\n"; } }

In reply to Re^4: How to stop printing the output of a command on screen when the command fails? by perl_mystery
in thread How to stop printing the output of a command on screen when the command fails? by perl_mystery

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.