Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I canít use a simple search and replace because the Article numbers change. Can Perl be used to do this?

Well fortunately Perl doesn't restrict you to simple search and replace, instead you have arguably the most powerful regular expression engine in the known universe! Perlre's eat changing numbers for breakfast whilst blindfolded with all eight limbs tied behind their backs. Some suggestions to add to Corion's sage advice:

  • figure out exactly how you identify the lines you want to change. Corion had to assume they were all starting with Article since you weren't specific about that
  • decide exactly how the lines may be constructed: are they always just letters and spaces, or may they have numerals, punctuation, carriage returns?

As a trivial solution I offer this simple modification of JavaFan's solution which you would apply line by line as you read through the file, but note it will not work if you have a different specification for the lines. I prefer to be as specific as I can in regular expressions, so know your data.


I'd like to be able to assign to an luser

In reply to Re: Simple Text Manipulation by Albannach
in thread Simple Text Manipulation by pseingalt

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (6)
    As of 2018-08-14 19:53 GMT
    Find Nodes?
      Voting Booth?
      Asked to put a square peg in a round hole, I would:

      Results (155 votes). Check out past polls.