BlueSaxman has asked for the wisdom of the Perl Monks concerning the following question:
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:And the sub in question:use strict; use warnings; use POSIX; use DBI; use Crypt::Eksblowfish::Bcrypt qw(bcrypt_hash); use Math::BaseCalc;
Thankyou all for your help :)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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Dividing a string into multiple substrings of different length
by BrowserUk (Patriarch) on Jan 04, 2015 at 05:37 UTC | |
|
Re: Dividing a string into multiple substrings of different length
by Anonymous Monk on Jan 04, 2015 at 07:20 UTC | |
|
Re: Dividing a string into multiple substrings of different length
by AnomalousMonk (Archbishop) on Jan 04, 2015 at 19:21 UTC | |
|
Re: Dividing a string into multiple substrings of different length
by nlwhittle (Beadle) on Jan 04, 2015 at 16:42 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |