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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



7stud
Enthusiast

Mar 21, 2010, 2:47 AM


Views: 992
Re: [jonny5509] Array problem


Quote
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:


Code
    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