$_="qwertyuiopasdfghjklzxcvbnm "; # string @b=(m{(.{10})(.{9})(.*)}); # @b = (qwertyuiop, asdfghjkl, 'zxc +vbnm '); @b=map{my@a=split//;$_=\@a;}@b; # this line makes a 2D array #net effect of above code is to make a 2D array of letters: # we could avoid the temp array @a by using: @b = ('qwertyuiop', 'asdfghjkl', 'zxcvbnm '); @b = map {[split//]}@b; # or alternatively we could: @a = ('qwertyuiop', 'asdfghjkl', 'zxcvbnm '); for (@a) {push @b, [split'',$_]} # we could even: @b = ( ['q','w','e','r','t','y','u','i','o','p'], ['a','s','d','f','g','h','j','k','l'], ['z','x','c','v','b','n','m',' '] ); $_="010422222033310333440222222210433333011333022220430222103044333301 +133022222220303333340240221022222043301333330122222030"; my@c=split//; # @c is simply an array of the values above 0..4 my$a=6;my$b=1; # init values for(@c){ $b--if($_==1); $a--if($_==2); $a++if($_==3); $b++if($_==4); # all we are doing is grubbing out the chars from the 2D array # based on the index in @c, I don't like this syntax much: print @{$b[$b]}[$a]if($_==0); # this array addressing syntax is cleaner I think print $b[$b][$a] unless $_; # you could also do this -> print @b->[$b][$a] unless $_; }
In reply to Re: Fun and Games
by tachyon
in thread Fun and Games
by iamcal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |