Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

what does $hash{$k} .= "{$v}"

by Anonymous Monk
on Feb 04, 2005 at 08:00 UTC ( [id://427975]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I'm viewing a code. Could somebody explain to me what does .= mean in the statement $hash{$k} .= "{$v}" where $k and $v are key and value of hash.

thanks,
riz

Retitled by davido from 'what does $hash{$k} .= "{$v}" class='add-text' size='.

Replies are listed 'Best First'.
Re: what does $hash{$k} .= "{$v}"
by davido (Cardinal) on Feb 04, 2005 at 08:24 UTC

    It is an assignment and a concatenation all in one. Here are a few other variants:

    $string .= " world."; # Concatenate and assign. Same as... $string = $string . " world."; $num += 5; # Add and assign. Same as... $num = $num + 5; $num -= 5; # Subtract and assign. Same as... $num = $num - 5; $num *= 5; # Multiply and assign. Same as... $num = $num * 5; $num /= 5; # Divide and assign. Same as... $num = $num / 5;

    Dave

Re: what does $hash{$k} .= "{$v}"
by Anonymous Monk on Feb 04, 2005 at 08:05 UTC
    It's an efficient way of writing:
    $hash{$k} = $hash{$k} . "{$v}";
    See man perlop.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://427975]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found