in reply to managing constants created with constant.pm

Well, you could do something along these lines:

{ my @constants = qw(scroll_x scroll_y flow_x flow_y); sub which_constants { my $self = shift; return undef unless ref($self); my %hashtest; @hashtest{map { $_ - 1 } grep(/^\d+$/ && 0<=$_ && $_<@constants,@_)} + = (); $self->{$constants[$_]} = exists $hashtest{$_} ? 1:0 for (0..$#const +ants); $self; } }

Of course, I'm assuming that your object is a blessed hashref. Is it pretty? Nope. But it does work and...ummm...yep. Hope this helps.

antirice    
The first rule of Perl club is - use Perl
The
ith rule of Perl club is - follow rule i - 1 for i > 1

Replies are listed 'Best First'.
Re: Re: managing constants created with constant.pm
by bakunin (Scribe) on Jul 14, 2003 at 09:36 UTC
    Thanks antirice!
    Yes they're all blessed hashrefs. I'll work on it. For me it's very pretty.Any code containing this triplet "grep,map, hash slice" has the "coolness factor". :))))))
    Ogla