Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Array Element Deletion

by rpike (Scribe)
on Dec 04, 2008 at 21:14 UTC ( [id://728103]=note: print w/replies, xml ) Need Help??


in reply to Array Element Deletion

I'll put it this way then. I have a hash whereby it has a key for each date in a range. Each date could have multiple people assigned. So I might have a hash entry like this :
$hash{"DEC012008"}[0] = "Mike"; $hash{"DEC012008"}[1] = "Steve"; etc..,
I want to randomly select one of the elements in the array assigned to the hash entry DEC012008 and then remove it from that array so, if I come back to that date, I don't reselect a person that was already selected.

Replies are listed 'Best First'.
Re^2: Array Element Deletion
by Krambambuli (Curate) on Dec 07, 2008 at 08:36 UTC
    It always pays to take a look onto when searching for a solution. It looks to me that Tie::Pick is exacly what you want.

    As for the list reference you might need, it's no crime to dereference it explicitely in order to use simpler structures , like say
    my $candidates_ref = $hash{"DEC012008"};
    Hth

    Krambambuli
    ---

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://728103]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-24 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found