in reply to constant name in variable
then i can make method calls like:use strict; use Carp; use constant { PREFIX => 1, SUFFIX => 2, TRUST => 3, DATE => 4, BUSINESS => 5, }; sub AUTOLOAD { my $self = shift @_; my $method = $AUTOLOAD; $method =~ s/.*:://; return if $method eq "DESTROY"; if ( $method !~ m/^Is(.+)$/ ) { confess "method = $method is not supported by AUTOLOAD!\n"; } my $token_type_value = eval( uc($1) ); if ( $@ ) { confess "invalid token type $1!\n"; } my ($token) = @_; return $self->_IsToken($token, $token_type_value); }
And _IsToken() does various tests, mostly against a list of known identifiers to determine if the token is of the type being asked about.$analyzer->IsSuffix("PhD");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: constant name in variable
by rir (Vicar) on Dec 02, 2002 at 22:01 UTC | |
by shemp (Deacon) on Dec 02, 2002 at 22:16 UTC |