I have written a script using sed to edit. Unfortunately the sed version is old and i have to edit file to another one, then copy over it. So i thought id give perl ago. I played around with pie but cannot work out how to pass variables to it and use line numbers. A basic version of my Script:
#!/usr/bin/ksh test1() { eval sed -e $1 testfile > testfile2 } test1 "'1s/.*/test /'" #test1 "'1s/.*/ '$(tput smso)'broken'$(tput rmso)' /'"
So i pass a string to another function, which is read by SED. I have to use line numbers due to duplicate text entries in the text file im editing. In the sed line, im saying edit the first line.Substitue anything in that line with the word test. The second test (commented out) does a reverse video to highlight that text. Can anyone give me pointers as to how i can write the above in perl.

In reply to Convert from Sed to Perl by mc007

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.