#! perl -slw use strict; use threads; use threads::shared; our $X :shared; $X ||= 10; our $Y :shared; $Y ||= 10; sub background { my $AoA = shift; while( 1 ) { $AoA->[ rand $Y ][ rand $X ]++; select undef, undef, undef, 0.01; } } my $AoA: shared = &share( [] ); @{ $AoA } = map{ &share( [] ) } 1 .. $Y; @{ $AoA->[ $_ ] } = (0) x $X for 0 .. $X-1; async \&background, $AoA; while( 1 ) { system 'cls'; print "@$_" for @{ $AoA }; select undef, undef, undef, 0.1; }