Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Strict to references of a particular Variable of particular type.

by Zaxo (Archbishop)
on Dec 02, 2005 at 13:00 UTC ( #513583=note: print w/replies, xml ) Need Help??


in reply to Strict to references of a particular Variable of particular type.

use Tie::Constrained; tie my $array_ref, 'Tie::Constrained', sub { ref $_[0] eq 'ARRAY' };
After that, an attempt to assign anything but an unblessed array ref will fail. Continuing,
tie my $hash_ref, 'Tie::Constrained', sub { ref $_[0] eq 'HASH' }; tie my $scalar_ref, 'Tie::Constrained', sub { ref $_[0] eq 'SCALAR' }; tie my $scalar_value, 'Tie::Constrained', sub { not ref $_[0] }; tie my $query, 'Tie::Constrained', sub { ref $_[0] and $_[0]->isa('CGI') }, CGI->new;
There are all kinds of possibilities.

After Compline,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://513583]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-08-04 17:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (33 votes). Check out past polls.

    Notices?