in reply to Can I empty a hash value?
#!/usr/bin/perl -w use strict; my %squares = ( a1 => $a1, a2 => $a2, a3 => $a3, b1 => $b1, b2 => $b2, b3 => $b3, c1 => $c1, c2 => $c2, c3 => $c3 ); my $response = <STDIN>; chomp ($response); &make_blank(\%squares, $response); print values %squares; print "\n"; print %squares; # makes the moved piece blank sub make_blank() { my $sq_hashref = shift; my $res = shift; if(exists $sq_hashref->{$res}){ $sq_hashref->{$res} = ''; } }
- Tom
|
|---|