Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-24-2002, 04:12 PM   PM User | #1
chrisvmarle
Regular Coder

 
Join Date: Jun 2002
Location: the Netherlands
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
chrisvmarle is an unknown quantity at this point
Multi Array problem(s)

I'm working on a todo-site, for myself and maybe to publish.

I'm trying to use Multi-Arrays, but the code below could (should) be shorter, I'm quite sure about that.

Here's the code:
Code:
	foreach $todo (@todos) {
		(@the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]) = split(/\|/,$todo);
		@test = split(/\|/,$todo);
		$n++;
	}
	@the_todos = sort date(@the_todos);
	@the_todos = sort priority(@the_todos);
	$n=0;
	foreach (@the_todos) {
		#print "@the_todos->[$n][0] @the_todos->[$n][1] @the_todos->[$n][2] @the_todos->[$n][3] @the_todos->[$n][4]<BR>";
		&print_todo(@the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]);
		$n++;
	}
@todos contains the info from the file like this:
1|To Do #1|1|1|95849384
The part that should be shorter is the
@the_todos->[$n][0],@the_todos->[$n][1],@the_todos->[$n][2],@the_todos->[$n][3],@the_todos->[$n][4]

Anyone any ideas on this or maybe a fresh, better idea?

Thanks in advance,
Chris
chrisvmarle is offline   Reply With Quote
Old 06-25-2002, 07:57 AM   PM User | #2
Astro-Boy
New Coder

 
Join Date: Jun 2002
Location: Sydney, NSW, Australia
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Astro-Boy is an unknown quantity at this point
Not 100% sure about this, but you might get away with:

Code:
foreach $todo (@todos) {
	push(@the_todos, @{ [ split(/\|/, $todo) ] });
}
- Mark
__________________
[ AstroBoy Online | Experiments in Stuff | Google, use it! ]
Astro-Boy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:02 AM.


Advertisement
Log in to turn off these ads.