DespacitoPerl:

Nice, but I'd work on the code formatting a bit, it's kinda funky, making it difficult to see what you're trying to do. Also, you don't want to use "my" everywhere, only when you're declaring/defining a variable. Further, if you set a default value to your variable, you only need to set it when it would change.

So the bit you have like this:

if (exists $identifier{$pins1}) { if ( ($w1 == $identifier{$pins1}{'w2'}) && ($h1 <= $identifier{$pi +ns1}{'h2'}) ) { my $start = 1; } else { my $start = 0; } } else { my $start = 0; } printf $output "$wline"; next if (my $start == 0);

could easily be changed to:

my $start = 0; if (exists $identifier{$pins1}) { if ( ($w1 == $identifier{$pins1}{'w2'}) && ($h1 <= $identifier +{$pins1}{'h2'}) ) { $start = 1; } } printf $output "$wline"; next if (my $start == 0);

Then, seeing how it's just a chained if statement, you could further reduce it to:

my $start = 0; if ( exists $identifier{$pins1} && ($w1 == $identifier{$pins1}{'w2'}) && ($h1 <= $identifier{$pins1}{'h2'}) ) { $start = 1; } printf $output "$wline"; next if ($start == 0);

There are other improvements you could make.

I might've answered your question, or I might not have, as I didn't actually see a question.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: Delete lines if matched expression by roboticus
in thread Delete lines if matched expression by DespacitoPerl

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.