perl: select elements of @
once again i'm 'fighting' with a little perl-script.
i have an @ with several elements.
looking like this:
2001-01-01;some text;url;blah;status;time
'
i choose the ones with 'status' active and put them in a new @:
foreach $line (@array) {
if ($array[4] eq "active") {
push @actives, $line;
}
}
now i'd like to compare the elements of @actives (based on 'time') and select only the ones, older than the newest 8 ones.
are you with me?
the ones selected, get another status (inactive).
well, i know how to sort the thing and i have several ideas how to select, but i suppose there must be an easier method than mine...?
i hope you understand, what i'm trying to do... my english, ahm, well, ...
Mark Hensler posted this at 15:37 — 21st June 2001.
He has: 4,048 posts
Joined: Aug 2000
You wanna make everything inactive except the newest 8 chronologically. Right?
Sort the array by time first. Then loop through each line with a FOR loop starting at record 9, and make everything inactive.
Mark Hensler
If there is no answer on Google, then there is no question.
merlin posted this at 05:40 — 22nd June 2001.
They have: 410 posts
Joined: Oct 1999
yesss, this would be a quite simple way... [thinking] i don't have to compare, i just take the first 8 and change the rest. [/thinking]
thank you mark! that's what i was looking for...
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.