Operator ->()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Can some one pls tell me wts the meaning of "$topIter->next()" ?
I know "->" is used for hash refs, but dont know when to use ->( ) !!!

Re: Operator ->()

Quoted text here. Click to load it

This calls the method next() on the object $topIter. Read the perlobj
documentation for more about this.

Quoted text here. Click to load it

Beside being used for method calls, '->' is also with references in
general for dereferencing. That is

  $aref->[0]     - Using an array reference as an array
  $href->   - Using an hash reference as an hash
  $sref->(1,2,3) - Using a subroutine reference (ie. call the sub)

Read more about this in the perlref documentation under 'Using
references', rule number 3.


Re: Operator ->()

Quoted text here. Click to load it

It invokes method "next" on the object contained in $topIter.

Quoted text here. Click to load it

Your example is not ->(), it is ->next(), or more generically, ->$method().
They are quite different.  The first is used on code-refs, the second on


-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Re: Operator ->()

Subra wrote:

[ exactly the same question as was posted to the beginners list a few
minutes earlier ]


Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Site Timeline