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.
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.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"; } } }
In reply to Re^2: string error message
by Marshall
in thread string error message
by sgmansell
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |