in reply to Re: string error message
in thread string error message
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"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: string error message
by ysth (Canon) on Jun 16, 2009 at 05:59 UTC | |
by Marshall (Canon) on Jun 16, 2009 at 06:20 UTC |