On 2012.06.07.20.21, sono...@fannullone.us wrote: > Would someone be so kind as to explain the following, or at least point > me to further reading? > > $item = > $main::global->{open}->{catalog}->SurfDB::split_line($main::global->{form}->{'itemid'}); > > The part I'm having trouble understanding is > "$main::global->{open}->{catalog}->". What does that do to the > split_line > sub that's being called? What does it do differently than just calling > SurfDB::split_line($main::global->{form}->{'itemid'}) by itself?
Good question. Let's break this into a few lines that are more-or-less equivalent: my $catalog = $main::global->{open}->{catalog}; my $itemid = $main::global->{form}->{'itemid'} my $item = $catalog->SurfDB::split_line($itemid); So that is just doing what you did mentally, I think, and clarifies the problem. If that line was instead: my $item = $catalog->split_line($itemid); then this would be a straightforward perl object-oriented call. The $catalog would be a blessed variable (an instance variable), and split_line would be a sub (method) in the package (class) that $catalog was blessed with. But instead we have a package name and sub spelled out explicitly, "SurfDB::split_line". So rather than perl using the package/class that $catalog belongs to it will use the SurfDB::split_line sub. Finally to your last question, how is this different than just calling the package::sub directly? With a method call the instance variable, in this case $catalog, always gets passed as the first parameter to the method. Usually people name it $self. The same thing happens here -- so this is equivalent to: my $item = SurfDB::split_line($catalog, $itemid); ... I think :) --Brock -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/