Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: print hash elements

by perl-diddler (Chaplain)
on Sep 13, 2016 at 13:16 UTC ( [id://1171671]=note: print w/replies, xml ) Need Help??


in reply to print hash elements

You could be very simplistic about it and use 'P' (a module in CPAN,
also, after fixing some syntax errors in your VAR statement):
> perl -we' use strict; use P; my $VAR1 = { "A1" => { "val1" => [23], "val2" => [42], "val3" => [15], + "val4" => [10] } ,"B1" => { "val1" => [13], "val2" => [22], "val3" = +> [25], "val4" => [11] }}; P "-----------\nvar=%s", $VAR1;' ----------- var={A1=>{val1=>[23], val2=>[42], val3=>[15], val4=>[10]}, B1=>{val1=> +[13], val2=>[22], val3=>[25], val4=>[11]}}
But if you are wanting an introduction to references, you might look at the book "Intermediate Perl" by Schwartz, foy & Phoenix (on amazon), Chapter 4, "Introduction to References". It's very important to understand what you are doing in the code if you want to print it out...

BTW -- what was "$hash" supposed to be in your 2nd line of your original code?

Replies are listed 'Best First'.
Re^3: print hash elements
by stevieb (Canon) on Sep 13, 2016 at 14:19 UTC

    ...or the in-core Data::Dumper...

    perl -wMstrict -MData::Dumper -E '...; print Dumper $VAR1'

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1171671]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found