I have a file with some data which i want to crunch into an AOH.Thed data corresp. to a record needs to be put into a hash.The data is of the form

Record#1:
name:'George Simpson'
age:25
occupation:'PLumber' ... so on

I use the following code to seperate the 'name'(to be the key of hash) & 'George Simpson'(to be the corresp value)

while(defined($index = <$inp_file>)) { if (($index =~ m"Record#") && ((keys %$hash_ref) != 0)) { return ($hash_ref); } next if ($index =~ m"Record#"); $index =~ m"(.*?): (.*)"; my $key = $1; my $val = $2; #1 $key =~ s"^\s+""g; #2 $key =~ s"\s+$""g; #3 $val =~ s"^\s+""g; #4 $val =~ s"\s+$""g; $hash_ref->{$key} = $val; }

Problem is that the four #ed lines above that i use to clean empty spaces is generating a warning which says :

Use of uninitialized value in substitution (s///)at f2ds4.pl at line 30 , <GENO> line 13

I am a bit lost here .. though the script runs and gives results, Id like to know which uninitialized value it is talking about ! thank you -pacman

edit by thelenm: added code tags


In reply to cleaning up spaces on either side of an extracted string by pacman

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.