That can delete too many lines.

01 keep 02 keep <- gets discarded by your code. 03 keep <- gets discarded by your code. 04 keep <- gets discarded by your code. 05 keep <- gets discarded by your code. 06 keep <- gets discarded by your code. 07 discard B5 08 discard B4 09 discard B3 10 discard B2 11 discard B1 12 somepat 13 somepat

That's in addition to the problems with $.-5 going negative.

By the way, splice would be more efficient than delete since it wouldn't shrink the allocated buffer.

I'm also trying to get the (-d) to be a stand-alone flag. What would be the best approach to this?

'd!' => \$delete,

-c ./someconfile

That's weird. Why not just print to STDOUT and redirect output? It's way more flexible at no cost.

perl dellines.pl -i somepat -d > someconfile

The name of the option doesn't even make sense. It's an output file, not a config file as far as the tool is concerned.


In reply to Re^3: Regex question by ikegami
in thread Regex question by jamsda

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.