CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
What does => do?

 



Batistuta
New User

Apr 14, 2013, 8:53 AM

Post #1 of 6 (382 views)
What does => do? Can't Post

Hi newbie here,

what does => do ?


Chris Charley
User

Apr 14, 2013, 9:21 AM

Post #2 of 6 (378 views)
Re: [Batistuta] What does => do? [In reply to] Can't Post

From the documentation, perldata.

Quote
It is often more readable to use the => operator between key/value pairs. The => operator is mostly just a more visually distinctive synonym for a comma, but it also arranges for its left-hand operand to be interpreted as a string if it's a bareword that would be a legal simple identifier. => doesn't quote compound identifiers, that contain double colons. This makes it nice for initializing hashes:

It is sometimes called the 'fat comma'. It is usually used to initialize a hash: key => 'value'


Batistuta
New User

Apr 14, 2013, 9:54 AM

Post #3 of 6 (373 views)
Re: [Chris Charley] What does => do? [In reply to] Can't Post

Great, thanks, what about -> ? and also what are the . . for
see attached code please, particularly the last line of this piece of code relating to packages:

package First;
$name = "first";
sub order() {return 1;}
package Last;
$name = "last";
sub order() {return 10;}
package main;
$name = "main";
sub order() {return 5;}
print "First is $First::name, Last is $Last::name,
this is $main::name or $::name or even $name\n";
print "First is ".First::order.", Last is
".Last::order.", this is ".main::order." or
".::order." or even ".order."\n";
print "First is also ".First->order.\n;

In Reply To


g4143
Novice

Apr 14, 2013, 11:20 AM

Post #4 of 6 (364 views)
Re: [Batistuta] What does => do? [In reply to] Can't Post

The -> is used for accessing a object's members.


Laurent_R
Veteran / Moderator

Apr 14, 2013, 11:48 AM

Post #5 of 6 (361 views)
Re: [g4143] What does => do? [In reply to] Can't Post

And also with references.


Batistuta
New User

Apr 15, 2013, 3:06 PM

Post #6 of 6 (349 views)
Re: [Laurent_R] What does => do? [In reply to] Can't Post

What about here, what is going on here, can anyone break this down for me please, very confusing...

my $hosts = Vim::find_entity_views(
view_type => 'HostSystem');
foreach my $host (@$hosts) {
print "host name ", $$host{name};
if (defined($host->QueryHostConnectionInfo()-
>serverIp))
{ print " Managed by: ",
$host->QueryHostConnectionInfo()->serverIp }
else
{print " Not managed" }
print "\n";
}

Code



      
    

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives