What is -> Symbol in perl

Showing Answers 1 - 18 of 18 Answers

nitashaa

  • Jul 14th, 2008
 

Arrow operator -> is used for deferencing references to array or hash.

$arr = ['1','2','3','4'];

To retrive the value of first element :
$val = $arr->[1];
Now variable $var will contain '2'.

  Was this answer useful?  Yes

shalusanju

  • Aug 13th, 2010
 

In object oriented PERL, the arrow -> symbol is used for creating or
accessing a particular object of a class.


For eg. in Perl/Tk


1. use Tk;
my $main_win = MainWindow->new();
Here we use -> to create a new object of the class MainWindow which belongs to
the package Tk.


2. $main_win->configure(-title => "Use of arrow symbol");
Here we use -> to access the 'configure' object of the class MainWindow and
assign a title to it.


  Was this answer useful?  Yes

soumdgr8

  • Aug 1st, 2015
 

Is used for chaining elements of a reference type. The element can be another reference, scalar, array, function, object

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions