Dear Monks,

I have written a sub to decode a sting of information from a 15 character base 36 input. I haven't tested it yet, however I believe it should work. My question is, where I have it splitting the data via substr as 5 separate lines, is there a simpler way of doing this, like splitting it into an array with a regular expression? It ends up returning it as an array anyway so if I can skip making the array that would be great.

My includes for reference:
use strict; use warnings; use POSIX; use DBI; use Crypt::Eksblowfish::Bcrypt qw(bcrypt_hash); use Math::BaseCalc;
And the sub in question:
sub ReadDaycode { # Get daycode. my $DC = $_[0]; # Divide daycode into its parts my $BoardTotal = $B10->to_base(substr($DC,0,4)); my $AvgSample = $B10->to_base(substr($DC,4,2)); my $Level = $B10->to_base(substr($DC,6,2)); my $Exp = $B10->to_base(substr($SC,8,5)); my $Fails = $B10->to_base(substr($DC,13,2)); return ($BoardTotal,$AvgSample,$Level,$Exp,$Fails); }
Thankyou all for your help :)

In reply to Dividing a string into multiple substrings of different length by BlueSaxman

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.