Click here to get back home

Operator ->()

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Operator ->() Subra 03-27-2008
`--> Re: Operator ->() Gunnar Hjalmars...03-27-2008
Posted by Subra on March 27, 2008, 9:37 am
Please log in for more thread options
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 ->( ) !!!

Posted by Peter Makholm on March 27, 2008, 9:49 am
Please log in for more thread options

> Can some one pls tell me wts the meaning of "$topIter->next()" ?

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

> I know "->" is used for hash refs, but dont know when to use ->( ) !!!

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.

//Makholm

Posted by xhoster on March 27, 2008, 12:01 pm
Please log in for more thread options
> Can some one pls tell me wts the meaning of "$topIter->next()" ?

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

> I know "->" is used for hash refs, but dont know when to use ->( ) !!!

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
objects.

Xho

--
-------------------- 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.

Posted by Gunnar Hjalmarsson on March 27, 2008, 3:35 pm
Please log in for more thread options
Subra wrote:

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

DO NOT DO THAT !!!

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

Similar ThreadsPosted
can I use 3 dot operator? September 4, 2004, 10:12 pm
what is the "=-" operator June 23, 2005, 2:34 pm
Use of the => operator March 29, 2006, 4:53 am
Bug of <= operator? June 9, 2006, 6:27 pm
the => operator January 15, 2007, 4:58 pm
Burned using the .. operator September 4, 2004, 8:41 am
Modulus Operator (%) September 22, 2004, 7:56 pm
<> the Diamond Operator December 31, 2004, 2:48 pm
comma operator April 21, 2005, 9:26 pm
regex for Err operator. August 23, 2005, 11:07 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap