NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
The future (Score:3, Insightful)
--
xoa
Re:The future (Score:1)
There's also an open source myth in there somewhere. (I should be writing that article, not eating a candy bar and reading use Perl;.)
There was a discussion on Perl Monks today about access checking. The poster just needed to check if a given user name is in the list of admins. That's pretty simple: just a hash look up.
While I normally use exists to avoid autovivification issues, one poster claimed that that was bad design. "What if you add administrative levels in the future and one of those levels
Re:The future (Score:1)
sub is_an_admin {
my($self, $user) = @_;
exists $self->{admins}{$user}; # Or whatever
}
When you're encapsulating a one line test that's an awful lot of stuff, but if you want maintainability you just have to bite the bullet (and the performance hit). Roll on Perl 6.
method is_an_admin { exists %.admins{$^user} }
However, I would like to add a loud "Hear! Hear!" to your main point.
Reply to This
Parent