Greetings esteemed monks,

I have read the online documentation on the s2p utility, and have tried to run it on my machine without success. The systems guys here do not know what Perl is, unless it has something to do with round, valuable shiny things out of which one could make a necklace, so they are no help—and they might take away Perl entirely if they knew I was fooling around with it. I have tried a number of ways to convert this sed script to Perl, but I finally must admit I need to see a correct version before I go any farther. Would someone please run s2p on this and post the result? Here’s my sed script:

/'1'/{ h d } /'2'/G /'2'/{ h d } /'3'/G /'3'/{ h d } /'4'/G /'4'/{ h d } /'5'/G

All this is doing is swapping one line for the next one if it contains these patterns. I’m trying to get this to work using the pattern of the following script, which works interactively with vi (alas, not Vim—we are so far in the dark ages here at my company, that I might get burned at the stake for mentioning it...) which modifies/ adds lines to a file based on patterns, and otherwise prints the lines just as they were:

#!/usr/bin/perl -w while (<>) { if (/'5'/) { s/[Nn]01/N01(+5) /g; s/'5'/'5';fac=5/g; s/^/NET1TOP BOX (NET);\n/g } etc… print "$_"; }

If someone could just get me started, I would really appreciate it. Thanks.


In reply to sed to perl conversion by NovMonk

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.