in reply to Re^2: trouble assigning values to hash
in thread trouble assigning values to hash

yes thanks for pointing that out. due to a route problem in the new office I can't tunnel into my desktop and grab the original code that I attempted to paste. I am pretty sure that I fixed it but I will have to wait until I get into the office to be sure. That'll teach me to post to this forum on my way out the door at the end of a busy day! ;)

Replies are listed 'Best First'.
Re^4: trouble assigning values to hash
by AnomalousMonk (Archbishop) on Aug 27, 2010 at 14:43 UTC

    Just one more picky observation concerning the updated OP code:

    The sub-pattern  \d+\d+\d+\d in the updated regex
        /(\d+\-\d+\-\d+\s\d+\d+\d+\d)/
    can be more concisely (and, IMHO, better) written as  \d{4,} ('four or more digits'). Moreover, I think I would use some formatting and fewer backwhacks to wind up with something like
        m{ (\d+ - \d+ - \d+ \s \d{4,}) }xms

      Thanks! I changed the line to this:

      if ( $line =~ /\d{4,}/ { $date = $1; }


      But the part that I think is causing the error is this one:
      else { $seqs{$sequence} = "$date;$orig;$desg;$body"; }


      Here is what the error looks like:
      [bluethundr@cc126-200:~/perl] $:./3par-test5.pl Use of uninitialized value in pattern match (m//) at ./3par-test5.pl l +ine 29, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1.




      For greater context, here is the loop in which this statement sits:
      while (<MYFILE>) { next if (m/^$/); last if (m/^Press.*/); my ( $line, %seqs, $sequence, $date, $orig, $desg, $body ); if ( $line =~ /\d\d:\d\d:\d\d/g { $date = $1; } else { $seqs{$sequence} = "$date;$orig;$desg;$body"; } }
      Thanks again!
        ... the part that I think is causing the error ...

        Yes, indeed! It's just as ikegami first said 'way back in Re: trouble assigning values to hash! The trouble starts with the statement
            my ( $line, %seqs, $sequence, $date, $orig, $desg, $body );
        in which a bunch of variables are defined and given no values. The 'Use of uninitialized value...' fireworks happen in the very next statement, which attempts to use all the uninitialized values (well, the scalars at any rate).

        Have a nice weekend. We look forward to your first post on this topic Monday morning. :)
        BTW: Your posted regexes still don't make any sense, but that's a discussion for Monday.