#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my %hash = ( a => [ '1','2', ], b => [ '2','3', ], c => [ '1','2', ], ); print Dumper \%hash; print "Delete whole key containing aref\n\n"; delete $hash{a}; print Dumper \%hash; print "Will turn to undef, perldoc -f delete says dont do it\n\n"; delete $hash{b}->[0]; print Dumper \%hash; print "Delete an element\n\n"; splice @{$hash{c}},0,1; print Dumper \%hash; # Returns $VAR1 = { 'c' => [ '1', '2' ], 'a' => [ '1', '2' ], 'b' => [ '2', '3' ] }; Delete whole key containing aref $VAR1 = { 'c' => [ '1', '2' ], 'b' => [ '2', '3' ] }; Will turn to undef, perldoc -f delete says dont do it $VAR1 = { 'c' => [ '1', '2' ], 'b' => [ undef, '3' ] }; Delete an element $VAR1 = { 'c' => [ '2' ], 'b' => [ undef, '3' ] };
In reply to Re: Removing duplicate values for a hash of arrays
by trippledubs
in thread Removing duplicate values for a hash of arrays
by perlvroom
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |