I have a program "execopu -text" that can take input from a file "file.txt" and execute the data inside by doing: execopu -text < file.txt from a Unix command line.

"file.txt" looks like this:
cell u csno = 7 ccuoosmin_3g1x = "" ccuoos_3g1x = "" u u csno = 12 ccuoosmin_3g1x = "" ccuoos_3g1x = "" u

I want to automate the generation of the "file.txt" and execution of the script into one Perl script. How can I modify this script to "<" redirect the output generated by the "print" statements using the same method as the Unix "<" but do this within perl instead? Right now the sript below is having issues using the "open" command.
#!/usr/bin/perl my @sitenumbers = (7,12); open(EXECOPU, '| execopu -text') or die("Can't run execopu: $!\n"); print EXECOPU "cell\n"; foreach my $site_number (@sitenumbers){ print EXECOPU <<"EOF"; u csno = $site_number ccuoosmin_3g1x = "" ccuoos_3g1x = "" u EOF }

In reply to Redirect Unix Input Within Perl by awohld

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.