CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Private Properties for Objects

 



dhoskin
New User

Nov 14, 2009, 2:17 PM

Post #1 of 3 (2003 views)
Private Properties for Objects Can't Post

I want to make private properties for objects using the following code.

sub SetProperty1 {
my ($self,$value)=@_;
$self =~ m/(0x(\w|\d){6}(\w|\d))/;
$property1{$1}=$value;
}

My question is...will the hex value for an object reference ever change.
(i.e. during garbage collection)


shawnhcorey
Enthusiast


Nov 14, 2009, 3:07 PM

Post #2 of 3 (2001 views)
Re: [dhoskin] Private Properties for Objects [In reply to] Can't Post


In Reply To
My question is...will the hex value for an object reference ever change.
(i.e. during garbage collection)


Yes, via threads. The technique you are attempting is called inside-out objects. They are not commonly used because of this. If you want to do objects in Perl, consider installing Moose. You may also want the Moose eXtensions at MooseX.

PS: you can read about inside-out objects on CPAN.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


dhoskin
New User

Nov 15, 2009, 7:37 PM

Post #3 of 3 (1962 views)
Re: [shawnhcorey] Private Properties for Objects [In reply to] Can't Post

thanks for the info. I'll check out moose.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives