http://www.perlmonks.org?node_id=867842

jjap has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I do get the data I need form the following code.
However the warnings probably indicates that there is something wrong with my structure.
use warnings; use strict; my $line; my $msgtype; my $bytes34 ; while (<DATA>) { chomp; next if ($_ =~ /^$/); # fixes the issue... $line = $_; $msgtype = substr $line, 6, 8; # keep only relevant type next if ( $msgtype ne "18FEF200") ; $bytes34 = substr $line, 26, 2; print "Line is: $line\n"; print "qty is: $bytes34\n"; } __END__ 0 18FEF200 X 8 00 00 FF FF 00 00 FF FF 17487.23877 +0 0 18FEF200 X 8 00 00 FF FF 00 00 FF FF 17487.13877 +0 0 18FEF200 X 8 0F 00 00 00 00 00 FF FF 17484.93861 +0 0 18FEF200 X 8 12 00 00 00 00 00 FF FF 17484.83858 +0 0 18FEF200 X 8 00 00 FF FF 00 00 FF FF 17486.83875 +0 0 18FEF600 X 8 FF 31 72 FF FF FF FF FF 17486.75931 +0 0 18FEF200 X 8 1E 01 00 00 00 00 FF FF 17321.32261 +0 0 18FEF200 X 8 2E 01 00 00 00 00 FF FF 17321.22202 +0 0 18FEF200 X 8 45 01 00 00 00 00 FF FF 17321.12260 +0 0 18FEF200 X 8 5A 02 00 00 00 00 FF FF 17016.19730 +0 0 18FEF200 X 8 75 02 00 00 00 00 FF FF 17016.09727 +0
Yields the 10 correct values followed by 5 warnings such as:
substr outside of string at parsefile.pl line 13, <DATA> line 12. Use of uninitialized value $msgtype in string ne at parsefile.pl line +16, <DATA> line 12.
Your indulgence and any hints will be greatly appreciated!
**update**
next if ($_ =~ /^$/); inserted to address possible empty lines, thanks to all