ImJustAFriend has asked for the wisdom of the Perl Monks concerning the following question:
There can be a variable number of label/data pairs on each line. My code for parsing these lines:label1=data1,label2=data2, ...
When I run the code, I get on my stderrmy @data = split(',', $line); foreach my $datapair (@data) { my ($label, $data) = split('=', $datapair); print "label: $label; data: $data\n"; print OUT1 "$data;"; }
I can see in my debug logs (further up, code not shown) that I am getting @data loaded appropriately with lines like my sample lines above. So why is $data uninitialized? This has been driving me nuts for a couple of hours now. Thanks all!Use of uninitialized value $data in concatenation (.) or string at ./t +est.pl line 124, <IN4> chunk 2147. Use of uninitialized value $data in concatenation (.) or string at ./t +est.pl line 125, <IN4> chunk 2147.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Use of uninitialized value $data
by Corion (Patriarch) on Nov 13, 2018 at 21:23 UTC | |
by ImJustAFriend (Scribe) on Nov 13, 2018 at 21:57 UTC | |
by Corion (Patriarch) on Nov 13, 2018 at 22:00 UTC | |
by Marshall (Canon) on Nov 14, 2018 at 01:12 UTC | |
|
Re: Use of uninitialized value $data
by LanX (Saint) on Nov 13, 2018 at 21:46 UTC | |
|
Re: Use of uninitialized value $data
by Marshall (Canon) on Nov 13, 2018 at 21:48 UTC | |
|
Re: Use of uninitialized value $data
by haj (Vicar) on Nov 13, 2018 at 21:48 UTC | |
|
Re: Use of uninitialized value $data
by hippo (Archbishop) on Nov 14, 2018 at 09:28 UTC | |
|
Re: Use of uninitialized value $data
by ImJustAFriend (Scribe) on Nov 13, 2018 at 22:00 UTC | |
by Marshall (Canon) on Nov 13, 2018 at 22:26 UTC | |
by Laurent_R (Canon) on Nov 13, 2018 at 22:18 UTC | |
by Marshall (Canon) on Nov 14, 2018 at 00:54 UTC | |
|
Re: Use of uninitialized value $data
by ImJustAFriend (Scribe) on Nov 15, 2018 at 21:48 UTC |