http://www.perlmonks.org?node_id=522808

Should the following two lines of code do the same thing?

$hash{$_} ||= 1 + keys %hash for @list; $hash{$_} = $hash{$_} || 1 + keys %hash for @list;

IMO the second one should be well defined. tye and diotalevi think that both are undefined, I could be conviced about the first, but I need more convincing on the second.

This came up because I was being cheeky in Re^3: Perl one-liner to remove duplicate entries from PATH and wound up scratching my head.

use Data::Dump::Streamer; my (%hash,%mash); @list=('A'..'C'); $hash{$_} ||= 1 + keys %hash for @list; $mash{$_} = $mash{$_} || 1 + keys %mash for @list; Dump(\%hash,\%mash)->Names('*hash','*mash')->Out(); __END__ %hash = ( A => 2, B => 3, C => 4 ); %mash = ( A => 1, B => 2, C => 3 );
---
$world=~s/war/peace/g