in reply to uninitialized value in hash element Error
You are not checking to see if the RE matches before trying to use $1 and $2. You should probably have something like:while (<FILE>){ /^(.*?): \s*(.*)$/; # Save text before colon in $1, and after # colon in $2 - Taken from the Camel Chp. 5.9 $fields{$1} = $2; # Creat %fields hash }
Update: As AM pointed out below, you may even need more error checking depending on what your output.txt file looks like. Another Update: If I make the change I pointed out above to the code, and run it against the output.txt you posted below, I do not get an error message.while (<FILE>){ if (/^(.*?): \s*(.*)$/) { # Save text before colon in $1, and aft +er # colon in $2 - Taken from the Camel Ch +p. 5.9 $fields{$1} = $2; # Creat %fields hash } }
|
|---|