I'm looking for help on where to start looking for the solution to a problem. I have a large amount of code, but I created a little subroutine to receive a file name (full path) and a substitution. The object is to open the file using the $^I variable for in-place editing, substitute some code for the passed in code, and then exit the subroutine. Very, very simple. I place the file name into @ARGV by simple assignment statement and then do a while ( <> ) { s/../../; print } loop. Very, very simple. The problem is that when it is run, Perl first asks for input from STDIN; when I hit Ctrl-D, it then opens the file and makes the substitution. I have made sure that the only thing in @ARGV is the file I want to change. I tried an experiment by copying the subroutine code verbatim and placing it into a separate file, made it executable, and then called it from within the subroutine, and it works without asking for input from STDIN. What could possibly be making my subroutine ask for STDIN if the code is run from within my program, but not when it is run from a separate process? Thanks for any help. wlh

In reply to In-Place Editing Problem by wlh4

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.