Hey all...

Vladi Belperchinov-Shabanski wrote:
[snip...]
and 'hidden loop' one:

   @a = ( 'E1', 'E2', 'E3', 'En' );
   $a = 1;
   map{ $a = { $_ => $a } } reverse @a;
   print Dumper( $a );

The problem with this one is that by doing this you destroy existing hashes. e.g. :


@a = ( 'E1', 'E2', 'E3', 'En' );
$a = 1;
map{ $a = { $_ => $a } } reverse @a;

@a = ( 'E1', 'Ex', 'Ey', 'Ez' );
$a = 1;
map{ $a = { $_ => $a } } reverse @a;
print Dumper( $a );

        gives :

$VAR1 = {
          'E1' => {
                    'Ex' => {
                              'Ey' => {
                                        'Ez' => 1
                                      }
                            }
                  }
        };

thus destroying the 'E2' entry (as well as all potential existing ones). Too bad, it was an elegant solution...

BTW I already searched for this problem before and have not found anything interesting besides the 'eval'.

        A+
--
   \^/
 -/ O \----------------------------------------
| |/ \|       Alexandre (Midnite) Jousset      |
 -|___|----------------------------------------
  • ... Zhuang Li
    • ... Jeff Yoak
    • ... Uri Guttman
      • ... Aaron Sherman
        • ... Uri Guttman
    • ... Vladi Belperchinov-Shabanski
      • ... Alexandre Jousset
        • ... Суханов Вадим
          • ... Alexandre Jousset
    • ... Ton Hospel
      • ... Yitzchak Scott-Thoennes
    • ... Yitzchak Scott-Thoennes
      • ... Alexandre Jousset
        • ... Yitzchak Scott-Thoennes
          • ... Alexandre Jousset
    • ... Andrew Pimlott
      • ... Alexandre Jousset

Reply via email to