in reply to Putting an array into a hash
I'd like to know what the error means, but the real question is how to transform an array into a hash.You can get more information on any error by putting "use diagnostics;" in your script (or looking up the error via perldoc perldiag or the splain utility).
...
%data = @info =~ /(\w+)\s*(\w+)/g; # Line that gives error
...
Applying pattern match to @array will act on scalar(@array) at e.pl line 29
$ echo 'Applying pattern match to @array will act on scalar(@array) at + e.pl lin e 29'|splain|fmt Applying pattern match to @array will act on scalar(@array) at e.pl li +ne 29 (#1) (W misc) The pattern match (//), substitution (s///), and transliteration (tr///) operators work on scalar values. If you apply one of them to an array or a hash, it will convert th +e array or hash to a scalar value -- the length of an array, or the population info of a hash -- and then work on that scalar value. This is probably not what you meant to do. See perlfunc/grep and perlfunc/map for alternatives.
|
---|