Am Montag, 2. Mai 2005 22.24 schrieb Paul Kraus:

> > >  if ((@{$info{$loggedin}}{cell}) and
> > >                 (@{$info{$loggedin}}{line} eq 'dc'))
> >
> > The person who wrote that is using a hash slice.  That would more
> > correctly be written as:
> >
> > if ( $info{$loggedin}{cell} and $info{$loggedin}{line} eq 'dc' )
>
> Why would you want to use a slice of a hash. Until just now I didn't
> even know you could do that.
> Doesn't seem to make sense to use a slice of an associative array
> unless you were just trying to cryptic.
>
> Can someone for the sake of discussion give an example of why you
> would want to use a slice of a hash?

use strict; use warnings;
my %h=(qw/a aa b bb c cc d dd e ee f ff/);
print "interesting values: ", join ", ", @h{qw/ a d f/};

# this prints:

interesting values: aa, dd, ff

So I can see a sense to use a hash slice - generally, and slicing more than 
one element.

But in the OP's example, It's still not clear to me why the hash data 
structure is used. Can anybody please shed some light on it?

joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to