[Templates] Adding delete method to HASH_OPS
[prev]
[thread]
[next]
[Date index for 2004/10/18]
Hi,
As above, I want a delete method for a hash key - ideally
Myhash.mykey.delete But that I guess would be a scalar method. So I'm
settling on Myhash.delete ("mykey")
I know I can manipulate the stash by doing something like:
$Template::Stash::HASH_OPS->{ reverse } = sub {
my $h = shift;
my %r = reverse %{$h};
\%r;
};
but, I want to modify the source so it will be available in all perl
programs without me having to do the above. So, I have
'delete' => sub {
my ($hash, $key) = @_;
delete $hash->{$key};
undef;
},
In $HASH_OPS in Stash.pm, but although this seems to work obviously it
working on a local copy of the hash. I don't like this syntax (although it
works) - Myhash = Myhash.delete ("mykey")
Is this the best way to approach the problem?
Cheers, jamie
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
[Templates] Adding delete method to HASH_OPS
Jamie Echlin 11:04 on 18 Oct 2004
|