G'day thnksnw,

You can do what you want using a label. Here's an example:

#!/usr/bin/env perl use strict; use warnings; for (qw{1 two -3 3.4 zero 0}) { print "$_ is ", get_num_type($_), "\n"; } sub get_num_type { my ($num) = @_; my $num_type; NUM_TYPE_TEST: { if ($num !~ /^-?\d+$/) { $num_type = 'non-integer'; last NUM_TYPE_TEST; } if ($num < 0) { $num_type = 'negative'; last NUM_TYPE_TEST; } if ($num == 0) { $num_type = 'zero'; last NUM_TYPE_TEST; } if ($num > 0) { $num_type = 'positive'; last NUM_TYPE_TEST; } } return $num_type; }

Output:

1 is positive two is non-integer -3 is negative 3.4 is non-integer zero is non-integer 0 is zero

Do note that this may not be the best course of action in your case; however, as you just posted a swathe of code out of context, I'm in no position to tell. I do see that you're splitting $input_line on a comma: if you're working with CSV files, consider using Text::CSV (which will run faster if you have Text::CSV_XS installed).

— Ken


In reply to Re: Best way to "Skip" a set of operations by kcott
in thread Best way to "Skip" a set of operations by thnksnw

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.