CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Data Dumper to print out hash values

 



newbie1000
New User

Nov 26, 2012, 9:53 AM

Post #1 of 7 (1284 views)
Data Dumper to print out hash values Can't Post

Can you tell me how to use Data Dumper to print out the values in the hashes in the code below.


#!/usr/bin/perl -w

use strict;
use App::Options (
options => [ qw(dbhost dbusername dbpassword homepage legacy) ],
option => {
storefront => {
description => "storefront location",
},
homepage => {
default => "/usr/local/apache/htdocs/",
},
legacy => {
default => "/usr/local/apache/htdocs/dir",

},
);

use Data::Dumper;


Laurent_R
Veteran / Moderator

Nov 26, 2012, 10:18 AM

Post #2 of 7 (1281 views)
Re: [newbie1000] Data Dumper to print out hash values [In reply to] Can't Post

Hi,


Code
use Data::Dumper;  
# ...
print Dumper %hash;
# or, better
print Dumper $hash_ref; # $hash_ref being a reference to the hash



newbie1000
New User

Nov 26, 2012, 10:32 AM

Post #3 of 7 (1279 views)
Re: [Laurent_R] Data Dumper to print out hash values [In reply to] Can't Post

Can you get me the snytax based on the code I posted?


Laurent_R
Veteran / Moderator

Nov 26, 2012, 10:49 AM

Post #4 of 7 (1277 views)
Re: [newbie1000] Data Dumper to print out hash values [In reply to] Can't Post

But you did not declare any hash, did you?


newbie1000
New User

Nov 26, 2012, 10:56 AM

Post #5 of 7 (1275 views)
Re: [Laurent_R] Data Dumper to print out hash values [In reply to] Can't Post

Well what I'm trying to do is print the value in storefront, homepage, legacy, and options. How do I do that?


Laurent_R
Veteran / Moderator

Nov 26, 2012, 2:20 PM

Post #6 of 7 (1270 views)
Re: [newbie1000] Data Dumper to print out hash values [In reply to] Can't Post

Well, I would suppose that the App::Options probably has a method (or function) to do that.

Else, you could probably peek into the code of this module to figure out the name of the hash where it probably stores these values, but that would be very bad practice, you are really not supposed to do that.


newbie1000
New User

Nov 26, 2012, 3:24 PM

Post #7 of 7 (1269 views)
Re: [Laurent_R] Data Dumper to print out hash values [In reply to] Can't Post

This is just all learning and practice for me. How would I like at the code of this module?

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives