I have a reference table that I want to put in a hash and then when I read in a given 
line with a matching key,
be able to pick up the array and assign the elements and manipulate the elements (not 
while they are part of hash.

Here is how I set up the hash:

%TITLES = ();
open(RTITLE, '/common/lib/rtitles') || die "Cant open rtitles: $!\n";
while (<RTITLE>) {
    unless (/^#/) {
        chomp;
        ($title, $rest) = split ' ', $_, 2;
        @fields = split ' ',$rest;
        $TITLES{$title} = [ @fields ];
    }
}

The records in rtitles look like this:

TAPE_EXTRACT_REPORT 0 0 0 0 0 0 0 0 0

I can print them out correctly with this:

for $line (keys %TITLES) {
    print "$line: @{ $TITLES{$line} }\n";
}

PROBLEM: I want to take the zeros which shortly will take on other values into 
variables when I get a key match. Here is my code to 
do that:

            foreach $keytitle (keys %TITLES) {
                if ( grep /$keytitle/, $lookup ) {
                    ($im, $rptid, $edate, $rdate, $unused) = split ' ', @{ 
$TITLES{$keytitle} }, 5 [1 2 3 4 5];
                    print "LookUp: $lookup\n";
                    print "Report Name: $rptname\n";
                    print "Receive Date: $rcvdate\n";
                    print "Process Date: $procdate\n";

                    print "IMAGE: $im    RPTID: $rptid   EFFDATE: $edate    RUNDATE: 
$rdate    UNUSED: $unused\n";
                    exit;

What I get out of the last print line is:

IMAGE: 9    RPTID:    EFFDATE:     RUNDATE:     UNUSED:

9 just happens to be the count of elements in an entry. My statement after the grep is 
patterned after the statement above PROBLEM that prints out the hash array but now 
doesn't work to pull out the elements. I obviously am getting a count. How do I get 
the elements of the string?

Man is this cool stuff, BUT it really hurts my poor brain.  I feel frazzeled after a 
days worth of Perling. Don't get me wrong, I love every minute of it, but at 60+ I 
think I need ear plugs 'cause it must be leaking out of my ears. :-)

TIA


--
-------------------------------------------------------------------------
"They that can give up essential liberty 
   to obtain a little temporary safety 
   deserve neither liberty  nor safety."                      

-- Benjamin Franklin 
-------------------------------------------------------------------------
RRRRR                Gary Luther
RR  RR               SAF
RR  RR UTABEGAS      2500 Broadway
RR RR                Helena, MT 59602
RRRR                 [EMAIL PROTECTED]
RR RR  ULE !!        
RR  RR               Visit our website at
RR   RR              http://www.safmt.org


BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Gary Luther
TEL;WORK:0631
ORG:;Computer Center
TEL;PREF;FAX:(406) 444-0684
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Luther;Gary
TITLE:Systems Administrator
END:VCARD

Reply via email to