#!/Perl/bin/perl -w use strict; use IO::File; use constant{KB => 2**10, MB => 2**20, GB => 2**30}; print "Enter the pathname and filename of the file to split: "; my $filename = <STDIN>; my $valid_block_type; my $block_size; my $block_type; until($valid_block_type) { print "Enter the block size \n (example: 400KB,10MB,1GB): "; $block_size = <STDIN>; chomp($block_size); $block_size =~ m{([a-zA-Z]{2}$)}; $block_type = $1; BLOCK_TYPE: { $block_type eq 'KB' && do{$block_type = KB; $valid_block_type = 1; last BLOCK_TYPE;}; $block_type eq 'MB' && do{$block_type = MB; $valid_block_type = 1; last BLOCK_TYPE;}; $block_type eq 'GB' && do{$block_type = GB; $valid_block_type = 1; last BLOCK_TYPE;}; DEFAULT_BLOCK_TYPE: {print "Invalid block type specified!\n\n" +;} } }
Generates the following warning msg. the line numbers correspond to the regex checks in the code block.
Use of uninitialized value in string eq at C:\Documents and Settings\x +xx\Desktop \deasm.pl line 32, <STDIN> line 3. Use of uninitialized value in string eq at C:\Documents and Settings\x +xx\Desktop \deasm.pl line 36, <STDIN> line 3. Use of uninitialized value in string eq at C:\Documents and Settings\x +xx\Desktop \deasm.pl line 40, <STDIN> line 3.
I understand that Perl wants me to decalre these strings in variables and reference them that way... but can someone explain why this is a bad practice?

20030728 Edit by Corion: Retitled as per authors intention


In reply to 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.