Based on several guesses, here's another approach to an SSCCE:

c:\@Work\Perl\monks>perl -wMstrict -e "my @lines = ( qq{.024. 3# keep this one \n}, qq{.024. 3# \n}, qq{.024. 3# keep this two \n}, qq{.024. 3#|a9780750247092|xisbn13\n}, qq{.024. 3# keep this three \n}, qq{.024. 3#|a0750247096|xisbn\n}, qq{.024. 3# keep this four \n}, ); print for @lines; print qq{\n}; ;; my $rx_first = qr{ [.] 024 [.] }xms; my $replace = '.020.'; ;; LINE: for my $line (@lines) { next LINE if $line =~ m{ \A $rx_first \s+ 3[#] [ ]{2} \Z }xms; $line =~ s{ \A $rx_first (?= .* [|]xisbn (?: 13)? \Z) } {$replace}xms; print $line; } " .024. 3# keep this one .024. 3# .024. 3# keep this two .024. 3#|a9780750247092|xisbn13 .024. 3# keep this three .024. 3#|a0750247096|xisbn .024. 3# keep this four .024. 3# keep this one .024. 3# keep this two .020. 3#|a9780750247092|xisbn13 .024. 3# keep this three .020. 3#|a0750247096|xisbn .024. 3# keep this four

Update: But pay attention to the Test::More approach hippo has used here: it's something you should be using generally in your development.


Give a man a fish:  <%-{-{-{-<


In reply to Re: Remove line and modify another by AnomalousMonk
in thread Remove line and modify another by Anonymous Monk

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.