Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Creating report

by Fletch (Bishop)
on Sep 08, 2020 at 19:29 UTC ( [id://11121491]=note: print w/replies, xml ) Need Help??


in reply to Creating report

You have more fields in a line (at least one) than you have columns in the header line. Just a WAG since you've not given any useful sample data but my guess is that you've got spaces in (say) what you expect to be coming as a single column (e.g. you have a street name with embedded spaces and your line is something like Fred New Sesame 12345). When you split that line you're getting four values in @fields and the undef error because you're accessing $field_names[3] which doesn't exist if your header line is Name Street Zip.

Problem is that your data format isn't the greatest so there's not really an obvious suggestion how to fix it. Theoretically you might presume the first and last fields are Name and Zip and treat however many appear in the middle as Street, but if your data has Names with embedded spaces that's going to fail as well. Better would be to step back and get your input data into a more amenable format (e.g. CSV wouldn't be bad (EDIT: and then use Text::CSV_XS or the like to parse it)).

The cake is a lie.
The cake is a lie.
The cake is a lie.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11121491]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-24 06:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found