Scarey having to deal with all of those numbers! I trust that they are coming from data or an external program and not being generated elsewhere in the script, as they are a debugging unfriendly way to pass information!

I second getting rid of the switch($subkey)

There's no harm in using:

if ( $subkey eq 1 ) { ... } elsif ( $subkey eq 11 ) { ... } ...
Also, in the 150 block where you have:
elsif($new1 == /1/){
down to:
elsif($new1 == /9/){
What are you expecting the string to be and what trying to test? ... a text match anywhere on the string:
elsif($new1 =~ /1/){
or a test for the actual exact number?
elsif($new1 eq 1){
or something else? I did this test myself how it would act:
#!/usr/bin/perl -w use strict; for my $new1 qw(1 11 a1a 1aa 001 010) { print "$new1 == /1/ : "; if ( $new1 == /1/ ) { print "YES\n"; } else { print "NO\n"; } print "-" x 10, $/; print "$new1 == 1 : "; if ( $new1 == 1 ) { print "YES\n"; } else { print "NO\n"; } print "-" x 10, $/; print "$new1 =~ /1/ : "; if ( $new1 =~ /1/ ) { print "YES\n"; } else { print "NO\n"; } print "-" x 10, $/; print "$new1 eq /1/ : "; if ( $new1 eq /1/ ) { print "YES\n"; } else { print "NO\n"; } print "-" x 10, $/; print "$new1 eq 1 : "; if ( $new1 eq 1 ) { print "YES\n"; } else { print "NO\n"; } print "=" x 10, $/; }
and was quite surprised by the results!
if ( $new1 == /1/ )
actually fails with:
Use of uninitialized value in pattern match (m//) at ./try.pl line 8.
if $new1 *is* 1 but on the other hand SUCCEEDS if $new1 is "a1a" !!!

In reply to Re: Perl Switch Errors on certain version by serf
in thread Perl Switch Errors on certain version by minixman

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.