It appears highly likely that you have a non-matching part of the regex that results in an undefined value some of the time. I would use something like code below to debug things. This assigns all of the individual var names into one array (@result) and avoids a mess with specifying each var name.

Run this on your data set and you see what it matching and what is not. Undefined is a "value" and I don't think that just checking scalar @result is enough. Anyway this should show where the program is failing to match, presumably on line 14 of the input.

my @result = # note @ variable not $variable !! (($beginning, $agency, $district, $ssn, $serv_per_m, $serv_per_y, $serv_per_t,.............); while (<IN>) { print; my @result = (.....blah) #see previous posters code my $token_nr=0; foreach my $token (@result) { $token_nr++; if (defined ($token) ) #if you try to print an undef { #program will bomb print "$token_nr++\t$token\n"; #this allows you to see exact +ly } #what is undef without progra +m else #bombing { print "$token_nr++\tUNDEFINED\n"; } } }
I suspect that your regex is too restrictive. Also fixed column files aren't that common but you may indeed have one. (\D) matches exactly one non-digit charater, to allow say somewhere between 1 and 4 non-digit characters, use (\D{1,4}). for a character set, use say  ([\d-]{9,11}) if ssn could be either 123-45-6789 or 123456789. Use \s* to indidicate zero or more space characters.

In reply to Re^2: string error message by Marshall
in thread string error message by sgmansell

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.