Gossamer Forum
Home : General : Perl Programming :

map{} and next?

Quote Reply
map{} and next?
Hi,

I've got a bit of a problem :/

Basically, I'm looping a hashref with;

Code:
map {
...
} keys %$var;

However, if you do;

Code:
map {
.. do something
if (something) {
next;
}
} keys %$var;

..it gives an error about the "next" not being valid outside a foreach().

Basically, I just need to know what the map{} equivilant of "next" is?

TIA

Andy

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] map{} and next? In reply to
Would grep not work better for you here?

~Charlie
Quote Reply
Re: [Chaz] map{} and next? In reply to
Hi,

Nope, it has to do a $DB->table(..)->count(), to see if any submissions are there (and if not, then do a "next").

Managed to get around it with for();

for (keys %$users) {
....
}

Which does allow "next". Thanks for the reply though Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] map{} and next? In reply to
Hi,

Do it with a for loop, it will probably end up being easier to read:

for (keys %$users) {
if (something) {
next;
}
...
}

Cheers,

Alex
--
Gossamer Threads Inc.