David Draley wrote: > I am trying to make a hash slice that only includes the keys "SHELL" and > "DB" for %unix - using a reference. How do I reference specific elements in > a % table? thanks
Hash slice is a list of values (for given keys). This two lines does the same: @slice = @unix{SHELL,DB}; @slice = ($unix{SHELL}, $unix{DB}); @slice array now contains two elements: "/bin/csh" and "mysql". But as far as I understood, you don't want a slice, but a second hash which will have only part of key/value pairs from the first one. Hash slice is an l-value, so you can assign one hash slice to another: @unix2{SHELL,DB} = @unix{SHELL,DB}; that way, %unix2 hash will have SHELL and DB values (and only those) the same as %unix hash. You can also store keys in array: @keys = qw(SHELL DB PAGER); @unix3{@keys} = @unix{@keys}; Is that what you need? In Perl 5 the funny character ($, @, %) means what the expression evaluates to. Hash slice is a list, so it starts with @ sign. However in Perl 6 this will change. - RaFaL Pocztarski, [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]