Following code represents multiple assignments in perl :-
1. ($a, $b) = (123, "123");
Here :-
$a = 123
$b = "123"
2. ($a , @b) = (123, "123", "456");
Here :-
$a = 123
@b = ("123", "456");
Note :- Same effect when @foo = (123, "123", "456");
And code is changed to ($a, @b) = @foo;
3. (@b , $a) = (123, "123", "456");
Here :-
@b = (123, "123", "456");
and $a is undefined as perl is greedy language and @b will swallow up as much of the array passed.
1. ($a, $b) = (123, "123");
Here :-
$a = 123
$b = "123"
2. ($a , @b) = (123, "123", "456");
Here :-
$a = 123
@b = ("123", "456");
Note :- Same effect when @foo = (123, "123", "456");
And code is changed to ($a, @b) = @foo;
3. (@b , $a) = (123, "123", "456");
Here :-
@b = (123, "123", "456");
and $a is undefined as perl is greedy language and @b will swallow up as much of the array passed.
No comments:
Post a Comment