in reply to Use of uninitialized value $data
Perhaps a regex is better?
#!/usr/bin/perl use strict; use warnings; $|=1; #turn of buffering for STDERR while (my $line = <DATA>) { next unless $line =~ /\S/; #skip blank lines my ($label, $data) = $line =~ /\s*(\w+)\s*=\s*(\w+)/; die "bad line: $line" unless defined $data; print "label $label is: $data\n"; } =prints label a is: 3 label b is: 4 label c is: 55 label d is: 99 bad line: x= Process completed with exit code 255 =cut __DATA__ a = 3 b=4 c = 55 d=99 x=
|
|---|