$time=$16; # Time Sample - 1000,000.00 @_1 = split "\,", $16; # Split the value in $16 (should be $time!) + where commas occur, put the results in @_1. (eg 1000 and 000.00) if($#_1 eq 0){ # if there is one value in @_1 (ie no comma +s in $time) $time = int ($time); # set $time to the integer value of $time } if($#_1 eq 1){ # if there are 2 values in @_1 (at least on +e comma) $time=$_1[0]; # set $time to the first value (1000 in my +example) $time=~ s/\,//g; # replace all the commas in $time with noth +ing $time*=1000; # multiply $time by 1000 } if($#_1 eq 2){ $time=1000;} # If there are 3 values in @_1 , set $t +ime to 1000 if($#_1 eq 3){$time=1000;} # If there are 4 values in @_1 , set $t +ime to 1000
It's terrible code, and I don't even think its working as it should (why set $time to $_1[0] and then replace commas which dont exist in there?)

I think overall it's trying to parse a number where the thousands are separated by commas, into an integer. I'm sure there are better ways/modules to do that.

C.


In reply to Re: split and compare by castaway
in thread split and compare by moked

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.