#!/usr/bin/perl use warnings; use strict; # demonstrates strict hash refs # Commonly seen error # Can't use string ("1") as a HASH ref while "strict refs" in use at ./z line my %box; my $x = 10; my $y = 10; my $z = 1; foreach my $X ( 0 .. $x ) { foreach my $Y ( 0 .. $y ) { # you cannot create a new hash depth by assigning # a value to it $box{$X}{$Y}{$z} = 1; #dosn't work and causes error below # $box{$X}{$Y}{$z}{'rect'} = 1 ; #works # $box{$X}{$Y}{$z}{'rect'} = undef ; #works $box{$X}{$Y}{$z}{'text'} = 2; #this gives strict refs error } }