Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does ($a,$b,$c) = @array mean in Perl?

Tags:

syntax

perl

I'd google it if I could but honestly I don't know what to search for (an inherent problem with symbol-heavy languages)!

($aSvnRemote, $aSvnLocal, $aSvnRef, $aSvnOptions) = @{$aSvnPair};

My guess is that $aSvnPair is an array of 4 values (in which case it's a very poorly named variable!) and this is just splitting it into specific variable identities...?

like image 731
devios1 Avatar asked Dec 04 '22 01:12

devios1


1 Answers

It's nothing more than a list assignment. The first value of the RHS is assigned to the first var on the LHS, and so on. That means

($aSvnRemote, $aSvnLocal, $aSvnRef, $aSvnOptions) = @{$aSvnPair};

is the same as

$aSvnRemote  = $aSvnPair->[0];
$aSvnLocal   = $aSvnPair->[1];
$aSvnRef     = $aSvnPair->[2];
$aSvnOptions = $aSvnPair->[3];
like image 77
ikegami Avatar answered Dec 24 '22 03:12

ikegami