http://www.perlmonks.org?node_id=1017008


in reply to Re: RFC on how I'm doing when it comes to writing objects?
in thread RFC on how I'm doing when it comes to writing objects?

Comments are in. Hope you find them helpful in pointing me in the right direction. I tested the 2 argument bless in the first subroutine. When it was data dumped, I didn't see any change in how the data was stored.

I went with the first one since it is the most straight forward. It does not have any of my other custom subroutines used in it and stands on its own.

sub accounts { my ($class) = @_; my @accounts = qw( Lady_Aleena LadyAleena_ABC LadyAleena_CBS LadyAleena_FOX LadyAleena_NBC LadyAleena_SyFy LadyAleena_TNT LadyAleena_USA LadyAleena_TV LadyAleena_eros LadyAleena_home LadyAleena_test ); return bless \@accounts, $class; }

After adding $class on the last line, the data dumped looked like...

$VAR1 = bless( [ 'Lady_Aleena', 'LadyAleena_ABC', 'LadyAleena_CBS', 'LadyAleena_FOX', 'LadyAleena_NBC', 'LadyAleena_SyFy', 'LadyAleena_TNT', 'LadyAleena_USA', 'LadyAleena_TV', 'LadyAleena_eros', 'LadyAleena_home', 'LadyAleena_test' ], 'Twitter::Objects' );

I got the same result without $class on the last line. When I use the subroutine as an object, I would do something like...

use strict; use warnings; use lib '../files/perl/lib'; use Twitter::Objects; my $accounts = Twitter::Objects->accounts; for my $account (@{$accounts}) { print $account; # and other code I want to run through this loop. }

I'm not sure what I'm missing.

Have a cookie and a very nice day!
Lady Aleena