pacman has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: cleaning up spaces on either side of an extracted string
by cLive ;-) (Prior) on Mar 19, 2004 at 07:48 UTC | |
by pacman (Initiate) on Mar 19, 2004 at 09:12 UTC | |
|
Re: cleaning up spaces on either side of an extracted string
by matija (Priest) on Mar 19, 2004 at 07:43 UTC | |
by pacman (Initiate) on Mar 19, 2004 at 09:02 UTC |