in reply to Re^4: Help editing a file based off seach criteria
in thread Help editing a file based off seach criteria

Now, what line number could the line have that is right before the current line (whose number you know)?

  • Comment on Re^5: Help editing a file based off seach criteria

Replies are listed 'Best First'.
Re^6: Help editing a file based off seach criteria
by perlnewb123 (Sexton) on Jan 13, 2009 at 16:47 UTC
    pos--;

      In your program you posted above, where did you use pos?

      Also, the pos function does not do what you might think what it does.

        You're right, using pos is only giving me the previous line number if I feed it $. Not sure how I would go about placing data to that line number. Any suggestions on a better route to take?
        #!/usr/bin/perl open DATA, "</home/file.conf"; while (<DATA>) { if(m/\END\b/) { print "$.\n"; print "$_\n"; $pos = $.; $pos--; print "$pos\n"; } } close(DATA);
        produces: Line #, Data, Previous Line #