in reply to Re: Arrays of hashes which have arrays
in thread Arrays of hashes which have arrays
my $yy = $test->{'divs'}; print ((join "\n", @$yy) . "\n");The extra parens are required to prevent print being interpreted as a function and seeing only the join, not the extra "\n".
You only really need one pair of parentheses and those should be around the arguments to join, and the concatenation (.) would, I think, be better as a comma since print is happy to work with a list.
my $yy = $test->{'divs'}; print join( "\n", @$yy ), "\n";
Another way to do this is to localise the list separator to a newline and, as you say, avoid the $yy temporary variable.
print do{ local $" = qq{\n}; qq{@{ $test->{ divs } }\n} };
I hope this is of interest. (Note, the use of quoting constructs, q{...} instead of '...' and qq{...} instead of "..." is a habit of mine so that one-liners work in *nix shells and at MS command prompts.)
Cheers,
JohnGG
|
|---|