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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.