CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [jonny5509] Array problem: Edit Log


Mar 21, 2010, 2:47 AM

Views: 2240
Re: [jonny5509] Array problem

At the moment, Im splitting each line on space and storing the values in an array, doing a scalar on the line array to get the number of values per line, which is fine, but how do I then add each value to a new array until it reaches the desired number, and then start on the next array?

split(), print(), count: split() a line into an array, then print() the numbers in the array one by one, and count after you print. After counting, use the modulus operator to tell you when to print a newline:

    if ( ($count % 6) == 0) { 
print "\n"}

Easy, peasy.

(This post was edited by 7stud on Mar 21, 2010, 2:50 AM)

Edit Log:
Post edited by 7stud (Enthusiast) on Mar 21, 2010, 2:48 AM
Post edited by 7stud (Enthusiast) on Mar 21, 2010, 2:50 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives