Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Extra Stuff

by qball (Beadle)
on Apr 17, 2001 at 02:32 UTC ( [id://72981]=note: print w/replies, xml ) Need Help??


in reply to Re: Extra Stuff
in thread Extra Stuff

Well, here's my solution:
foreach $rec (@CUSTDATA) { chomp $rec; @array = split(/,/,$rec); #count number of elements in array for error checking $num_of_elements = scalar @array; if($num_of_elements == '14'){ do whatever... @array[0]...@array[10]... } }

Should work well...I'm currently testing it now, so we'll see what happens.

qball~"I have node idea?!"

Replies are listed 'Best First'.
Re: Re: Re: Extra Stuff
by jynx (Priest) on Apr 17, 2001 at 03:52 UTC

    You may want to clean this code up a bit. Namely, the $num_of_elements variable is unnecessary and your check for '14' items should check for 14 items instead. Something like:
    #make sure we have the right number of elements carp "Incorrect number of elements" if @array != 14; #continue with the program...
    Since you're checking the @array against a number it's automatically in scalar context. Also, putting it in one line allows you to continue your program without wrapping a large chunk of code in an if statement, which could confuse readability (where did this `}' come from?).

    Hope That Helps,
    jynx

Re (tilly) 3: Extra Stuff
by tilly (Archbishop) on Apr 17, 2001 at 04:01 UTC
    So you are dropping data, don't know why, and have chosen to not log or investigate?

    I am glad that is not my data!

    Before going with a band-aid like this, you should go through the files looking for lines that don't split into 14 parts and try to figure out the cause...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2024-04-26 06:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found