Hello monks, I am in need of assistance please. I have a file I am parsing. At the end of parsing, I am left with lines that look like this:
label1=data1,label2=data2, ...
There can be a variable number of label/data pairs on each line. My code for parsing these lines:
my @data = split(',', $line);
foreach my $datapair (@data) {
my ($label, $data) = split('=', $datapair);
print "label: $label; data: $data\n";
print OUT1 "$data;";
}
When I run the code, I get on my stderr
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.
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!