W1SDM has asked for the wisdom of the Perl Monks concerning the following question:
Because of legacy issues, I have loaded the @result array at the first element rather than the zeroth. This isn't a huge deal, but it does eliminate the need to adjust the other parts of the program.#! /usr/local/bin/perl use strict; use warnings; # Setup the situation my $string = "BEHACJBDLCENADFEGOFHQAGIHJRBIKJLSCKMLNTDMOFNPOQTGPRIQSKR +TMPS"; my ($i, $j, @array, @result); # Perform the task @array = split //, $string; for $i (1..20) { for $j (1..3) { $result[$i][$j] = ord(shift(@array)) - 64; } } # Print the results for $i (1..20) { for $j (1..3) { print sprintf("%02d", $result[$i][$j]) . " "; } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Split a string into a list of lists
by GrandFather (Saint) on Feb 06, 2009 at 06:45 UTC | |
|
Re: Split a string into a list of lists
by fullermd (Vicar) on Feb 06, 2009 at 06:10 UTC | |
|
Re: Split a string into a list of lists
by BrowserUk (Patriarch) on Feb 06, 2009 at 10:20 UTC | |
|
Re: Split a string into a list of lists
by johngg (Canon) on Feb 06, 2009 at 10:20 UTC | |
|
Re: Split a string into a list of lists
by AnomalousMonk (Archbishop) on Feb 06, 2009 at 09:49 UTC | |
|
Re: Split a string into a list of lists
by gone2015 (Deacon) on Feb 06, 2009 at 10:32 UTC |