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: Beginner:
Spliting up rows using %

 



S_Shrum
User

Mar 19, 2001, 2:58 PM

Post #1 of 2 (387 views)
Spliting up rows using % Can't Post

I wrote a script that returns the contents of the specified path in a table. Currently, I have the code set up as <snippet>:

# display the filenames in a table
foreach (sort @filenames) {
print "<td align=center><a href=\"/$input{'path'}/$_\">$_</a></td>";
if ( $count % 3 ) { print "</tr><tr>"; }
$count++;
}

in order to determine if I need to start a new table row.

I am in the process of adding customization to the script but find that when I us a number other than 2 the table rows get messed up. If I use "3", I get:

filename filename
filename
filename filename
filename
...

If I use 4 I get:

filename filename
filename
filename
filename filename
filename
filename
...

What am I doing wrong?



Sean Shrum
sean@shrum.net
www.shrum.net


japhy
Enthusiast

Mar 20, 2001, 12:15 PM

Post #2 of 2 (378 views)
Re: Spliting up rows using % [In reply to] Can't Post

You're doing $x % 3, which is true 2 out of 3 times. You want $x % 3 == 0 which is true 1 out of 3 times.

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author

 
 


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

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