#! perl -slw use strict; use Data::Dump qw[ pp ]; sub alias{ \@_ } my $label = 'aa'; my @rows = map{ [ map{ $label++ } 1 .. 9 ] } 1 .. 9; my @cols; for my $col ( 0 .. 8 ) { push @cols, alias( $rows[ 0 ][ $col ], $rows[ 1 ][ $col ], $rows[ 2 ][ $col ], $rows[ 3 ][ $col ], $rows[ 4 ][ $col ], $rows[ 5 ][ $col ], $rows[ 6 ][ $col ], $rows[ 7 ][ $col ], $rows[ 8 ][ $col ], ); } my @sqrs; for my $y ( 0 .. 2 ) { for my $x ( 0 .. 2 ) { push @sqrs, alias( $rows[ $x *3 + 0 ][ $y * 3 + 0 ], $rows[ $x *3 + 0 ][ $y * 3 + 1 ], $rows[ $x *3 + 0 ][ $y * 3 + 2 ], $rows[ $x *3 + 1 ][ $y * 3 + 0 ], $rows[ $x *3 + 1 ][ $y * 3 + 1 ], $rows[ $x *3 + 1 ][ $y * 3 + 2 ], $rows[ $x *3 + 2 ][ $y * 3 + 0 ], $rows[ $x *3 + 2 ][ $y * 3 + 1 ], $rows[ $x *3 + 2 ][ $y * 3 + 2 ], ); } } $sqrs[ 4 ][ 4 ] = 9; ## Modify one view ## The change apppears in all views. pp 'rows', \@rows; pp 'cols', \@cols; pp 'sqrs', \@sqrs; __END__ C:\test>sudoku.pl ( "rows", [ ["aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai"], ["aj", "ak", "al", "am", "an", "ao", "ap", "aq", "ar"], ["as", "at", "au", "av", "aw", "ax", "ay", "az", "ba"], ["bb", "bc", "bd", "be", "bf", "bg", "bh", "bi", "bj"], ["bk", "bl", "bm", "bn", 9, "bp", "bq", "br", "bs"], ["bt", "bu", "bv", "bw", "bx", "by", "bz", "ca", "cb"], ["cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck"], ["cl", "cm", "cn", "co", "cp", "cq", "cr", "cs", "ct"], ["cu", "cv", "cw", "cx", "cy", "cz", "da", "db", "dc"], ], ) ( "cols", [ ["aa", "aj", "as", "bb", "bk", "bt", "cc", "cl", "cu"], ["ab", "ak", "at", "bc", "bl", "bu", "cd", "cm", "cv"], ["ac", "al", "au", "bd", "bm", "bv", "ce", "cn", "cw"], ["ad", "am", "av", "be", "bn", "bw", "cf", "co", "cx"], ["ae", "an", "aw", "bf", 9, "bx", "cg", "cp", "cy"], ["af", "ao", "ax", "bg", "bp", "by", "ch", "cq", "cz"], ["ag", "ap", "ay", "bh", "bq", "bz", "ci", "cr", "da"], ["ah", "aq", "az", "bi", "br", "ca", "cj", "cs", "db"], ["ai", "ar", "ba", "bj", "bs", "cb", "ck", "ct", "dc"], ], ) ( "sqrs", [ ["aa", "ab", "ac", "aj", "ak", "al", "as", "at", "au"], ["bb", "bc", "bd", "bk", "bl", "bm", "bt", "bu", "bv"], ["cc", "cd", "ce", "cl", "cm", "cn", "cu", "cv", "cw"], ["ad", "ae", "af", "am", "an", "ao", "av", "aw", "ax"], ["be", "bf", "bg", "bn", 9, "bp", "bw", "bx", "by"], ["cf", "cg", "ch", "co", "cp", "cq", "cx", "cy", "cz"], ["ag", "ah", "ai", "ap", "aq", "ar", "ay", "az", "ba"], ["bh", "bi", "bj", "bq", "br", "bs", "bz", "ca", "cb"], ["ci", "cj", "ck", "cr", "cs", "ct", "da", "db", "dc"], ], )