Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

tadman's scratchpad

by tadman (Prior)
on Jun 05, 2004 at 11:57 UTC ( #361499=scratchpad: print w/replies, xml ) Need Help??

In the course of creating a sort of "restricted" scalar type, I've d The idea is to create a variable which is restricted, for example, a scalar which can only contain a fixed number of characters. Ideally, it would work something like this:
my $super_scalar = SuperScalar->new(length => 15);
Which would make $special_scalar type 'SuperScalar', though as you can see, the mechanics of this are not so simply implemented.

So far, I have to make $special_scalar a reference to the actual "special scalar" tie'd variable, which means when you use this thing it gets all messy:
$super_scalar = "Something Really Big..."; print $super_scalar,"$_\n"; # Prints "Something Reall\n"
The limitation, it seems, is that when a scalar imports a value from another, it doesn't import the tied type.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2023-12-10 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (39 votes). Check out past polls.

    Notices?