in reply to Re^2: Global variable unexpectedly modified when passed by reference
in thread Global variable unexpectedly modified when passed by reference

Thanks, de-referencing the passed hashref and operating on that does what I need, as this one-liner demonstrates :

perl -w -MData::Dumper -e 'use strict; my $hash = {a => 1, b => 2}; sub mysub{my $h = shift; my %dh = %$h; delete $dh{"b"}}; mysub($hash); print Dumper($hash)'
  • Comment on Re^3: Global variable unexpectedly modified when passed by reference
  • Download Code