Hello respected Monks,
Here is my question
I have a line of code like so: "$dub_key => $dub_values\n";
that prints
dubhpr28.hpux => ARRAY(0x4002e1bc)
but I want to have printed out the values contained in the $dub_values arrayref instead of its address.
What do I have to change to achieve this?
My Goal is below
key=>dubhpr01.hpux
values=>name,uid,gid,comments.
dublin_aref = \@dublin_array.
@dublin_arry contains a glob like so:
glob("/home/user/passwd.*)
dub_values are the values within the hash %dublin_hosts while dub_key is the regexp from the filenames that is the key within the hash %dublin_hosts.
As an example, each key is the regexp of each file name from the array reference: passwd.dubhpr01.hpux after being parsed by my regexp I get dubhpr01.hpux
Each values are the various fields in the passwd files.
Here is the snippet of code I am working on now:
1 use strict;
2 use warning;
3 use diagnostics;
4
5 my @dublinaray = glob("/home/user/passwd.*");
6 my $dublin_aref = \@dublinaray;
7 my (%dublin_hosts) = ();
8 my ($dub_key,$dub_values,);
9
10 parse_file();
11
12
13 sub parse_file {
14 foreach my $element ( @{$dublin_aref} ) {
15 { local *FILE;
16 open (FILE, "+<$element") or die "dublin reference
did not open: $!";
17 local $/ = undef;
18 ($dub_key) = $element =~ m|\.(\w+\.\w+)\z|i;
19 ($dub_values) = split /:/, <FILE>;
20 push ( @{$dublin_hosts{$dub_key}}, $dub_values );
21 print Dumper("KEY\t",$dub_key,"\n\n");
22 print Dumper("ELEMENTS\t",$element,"\n\n");
23 print Dumper("DUB VALUES\t",$dub_values,"\n\n");
24 }
25 }
26 while ( ($dub_key,$dub_values) = each %dublin_hosts )
{
27 print Dumper("$dub_key => $dub_values\n");
28 }
29
30 } ##-- END SUB --##
## thank you!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.