Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Re: Tying with a class method

by ninja-joe (Monk)
on May 02, 2002 at 16:49 UTC ( [id://163593]=note: print w/replies, xml ) Need Help??


in reply to Re: Tying with a class method
in thread Tying with a class method

I was under the impression that "use strict" would disallow me from using package level variables. I'm probably wrong though. Suppose if I wanted to make a hash a member of that class, regardless of whether strict minded or not, would it just work like: $self->hash{"foo"} = "bar"; and %self->hash ? Where I'd be able to do a statement such as
tie %self->hash, "AnyDBM_File", "data", O_RDWR, 0644;

Replies are listed 'Best First'.
Re: Re: Re: Tying with a class method
by broquaint (Abbot) on May 02, 2002 at 17:09 UTC
    I was under the impression that "use strict" would disallow me from using package level variables
    The use of strict merely discourages the use of package variables. As long as a variable exists within the package's symbol table you're free to use it without it being fully qualifying.

    If you had a hash as a data member of the blessed object (which itself was a hash) then you would use it like so

    # assign to hash $self->{hash}->{foo} = 'bar'; # get keys from hash keys %{$self->{hash}}; # tie hash tie %{$self->{hash}}, "AnyDBM_File", "data", O_RDWR, 0644;
    If you're a little confused about how how classes and objects work I'd recommend reading Tom Christiansen's oo tutorial and perhaps also read up on references in perl.
    HTH

    _________
    broquaint

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found