Hope you all are doing good ! I want to use a variable from script "b.pl script" and "b.pl script" uses a package from "a.pm". In my present "c.pl script" I'm using

require 'b.pl'

so as soon as this line executes, it will run the script "b.pl script". but I need to re-direct the output of "b.pl script" to a text file. Earlier I used to run as

Perl b.pl > textfile.txt

separately but now as I need to access a variable from "b.pl script" I use "require" keyword in "c.pl script" but as it is running the "b.pl script", so I need to do output redirection also. Please suggest me how can I do output rediretion when I'm using require keyword Is it like this ?

require 'b.pl > textfile.txt'

but this seems not working. Please tell me what mistake I'm doing here, is there any way to redirect the output of "b.pl" script without using redirection operator ">". Thanks in advance.


In reply to Output redirection using “require” in perl by Sandeep Kumar

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.