[Purdue-pm] More on Mark's challenge

Phillip San Miguel pmiguel at purdue.edu
Tue Jan 19 11:54:41 PST 2010

With regards to the solution I had using 'split', it does work:

#split plus hash slice method
my %here                  =split;
my @p                 =@here{0..127};
@p[0..32,127..255]    =split //, q{.}x32 .q{ } .q{.}x129;

But it does require no pattern to be specified to invoke the desired 
magic. From perldoc -f split:

     split /PATTERN/,EXPR
     split /PATTERN/

             If EXPR is omitted, splits the $_ string.  If
             PATTERN is also omitted, splits on whitespace (after
             skipping any leading whitespace).

PS I have updated my "golf" solution to 43 characters:

@p=(('.')x32,' ',/\d+\s(\S)\s/g,('.')x129);

Commented, it isn't even difficult to understand:
 @p         =(    ('.')x32               #1st 32 characters are '.'
                ,' '                    #the requisite space
                ,/\d+\s(\S)\s/g         #capture 1 character records
                ,('.')x129              #round out to 256 elements

But it is brittle...

More information about the Purdue-pm mailing list