G'day lightoverhead,

As has already been pointed out, using symbolic references this way is a bad idea. If you're interested purely for academic reasons, see "perlref: Symbolic references"; understanding the refs stricture of the strict pragma would also be useful.

As an alternative, consider the technique in this script (and see the Notes at the end):

#!/usr/bin/env perl use strict; use warnings; use Inline::Files; my %master_hash; my @filehandles = (\*FILE1, \*FILE2, \*FILE3); for (0 .. $#filehandles) { my $fh = $filehandles[$_]; my $wow_key = "wow$_"; while (<$fh>) { chomp; push @{$master_hash{$wow_key}{(split /\t/)[1]}}, 'sth'; } } use Data::Dump; dd \%master_hash; __FILE1__ x file1line1 x file1line2 __FILE2__ x file2line1 x file2line2 __FILE3__ x file3line1 x file3line2

Output:

{ wow0 => { file1line1 => ["sth"], file1line2 => ["sth"] }, wow1 => { file2line1 => ["sth"], file2line2 => ["sth"] }, wow2 => { file3line1 => ["sth"], file3line2 => ["sth"] }, }

Notes

-- Ken


In reply to Re: How to correctly use a symbolic reference to automatically generate hash names? by kcott
in thread How to correctly use a symbolic reference to automatically generate hash names? by lightoverhead

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.