Hi Folks,
I have a package as in:
package Library;
sub new {
my ($class, $fname) = @_;
my $self = {
library => undef
};
bless $self, $class;
my $lib = Data::Container->new();
my $libfile = Data::File->new($fname);
$lib->read($libfile);
($self->{library}) = ($lib->get_list("library"));
return $self;
}
sub get_list {
my ($self, @keywords) = @_;
return $self->{lib}->get_list(@keywords);
}
where Data::Container is another package as below:
package Data::Container;
sub new {
my $class = shift;
my $self = {
line => shift,
items => undef,
close => undef,
};
$self->{line} = "" unless $self->{line};
bless $self, $class;
}
and similarly, Data::File is another package as below:
package Data::File;
sub new {
my $class = shift;
my $self = {
file => iFile->new(shift)
};
bless $self, $class;
}
Note that the above code does not contain the methods (I excluded them for making my post to be compact).
In the above code, in the package Library, I have the line
($self->{library}) = ($lib->get_list("library"));
If I do not use the paranthesis like above and have instead:
$self->{library} = $lib->get_list("library");
I get an error.
Please excuse if this is a very basic question...but why do I need to use the
($self->{library}) = ($lib->get_list("library")); instead of
$self->{library} = $lib->get_list("library"); to make my program work?
--Jessica
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.