in reply to Assigning an array of strings to a hash value in an array of hashes
You have to force split into a list, before assigning it to the hash using square brackets . This discussed in this node about array and list context
>./test.pl some,kinda,sick,joke #!/usr/bin/perl -w use strict; use Data::Dumper; my @files=[ {foo=>[qw/this that other/], bar=>[qw/them those they/]}, {foo=>[qw/up down left right/], bar=>[qw/spin turn veer/]} ]; ################# Square brackets round split ###### $files[2]{foo} = [ split(/,/,$ARGV[0]) ]; print Dumper @files; __DATA__ $VAR1 = [ { 'foo' => [ 'this', 'that', 'ottther' ], 'bar' => [ 'them', 'those', 'they' ] }, { 'foo' => [ 'up', 'down', 'left', 'right' ], 'bar' => [ 'spin', 'turn', 'veer' ] } ]; $VAR2 = undef; $VAR3 = { 'foo' => [ 'this', 'that', 'other' ] };
|
|---|