Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Hash slice again (NOT)

by rir (Vicar)
on Jan 28, 2009 at 21:05 UTC ( [id://739702]=note: print w/replies, xml ) Need Help??


in reply to Hash slice again

In your update, you are mixing up arrays and hashes. You imply this code, which you should have shown to your helpful friends use strict and use warnings:
@a = (a,b,c); undef @a[1,2]; @a = (a,b,c);
undef @a{@a};# there is no hash you probably want something like this:
@array = ( 'a', 'b', 'c', 'd', 'e' ); %hash = ( a => 0, b => 1, c => 2, d => 3, e => 4 ); @indices = ( 2, 3); @keys = ( 'c', 'd' ); undef @array[ @indices ]; # undefs value of/in @array[3] undef @hash{ @keys }; # undefs value of/in $hash{d} use Data::Dumper; print Dumper \%hash; print Dumper \@array; __END__ $VAR1 = { 'e' => 4, 'c' => 2, 'a' => 0, 'b' => 1, 'd' => undef }; $VAR1 = [ 'a', 'b', 'c', undef, 'e' ];
Be well,
rir

Replies are listed 'Best First'.
Re^2: Hash slice again (NOT)
by ikegami (Patriarch) on Jan 28, 2009 at 21:54 UTC

    He's asking why 'c' is still in the array. Even with your fix, it's still in the array.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2024-04-19 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found