The -w option generates warnings. They are not critical errors, but more a hint that some things might not be what you think they are. If you feel confident in your code, you can choose to ignore them, and your program will continue running as it did before, but in most cases, you get the warnings because of some deeper errors within your programming.

In the program, perl warns you because you are trying to compare a scalar with no value to a scalar with a string value, and this happens in lines 32, 36 and 40. This is most likely, because one of the two sides of a comparision contains a scalar that was never initialized properly.

In your case, you are trying to capture a match and then using the captured string, without checking whether the match actually succeeded :

$block_size =~ m{([a-zA-Z]{2}$)}; $block_type = $1;
A better way whenever you are matching things is :
$block_size =~ m{([a-zA-Z]{2}$)} or die "I could not find the block type in the string '$block_si +ze'"; $block_type = $1;
</code> because here, you can always be sure that $block_size was what you expected it to be and $block_type contains a meaningfull value.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

In reply to Re: why is this code bad under -w option? by Corion
in thread why is this code bad under -w option? by Grygonos

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.