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

In reply to Are these warnings indicative of a problem with the structure? (Baby Perl, easy xp... ;-) by jjap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.