On Jul 23, 1:51 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> John W. Krahn wrote:
> > jeevs wrote:
>
> >> I just wanted to know what does the following line do....
> >> @{$args{owner}} = qw(hero wierd);
>
> > You are assigning a list to the anonymous array in $args{owner}.
>
> >> lets assume $args{owner} = 'sachin';
>
> > 'sachin' is a scalar value.
>
> >> Then it would mean @{sachin} = qw(hero wierd);
>
> > No, the scalar value is replaced with an anonymous array.
>
> >> what would {sachin} stand for does it mean an hash refernce or
> >> something else. I am lost.
>
> > 'sachin' would not exist after the assignment.
>
> Correction, the assignment wouldn't happen:

No, the assignment happens just fine.  It's just not assigning to what
you think it's assigning to.

The OP was using symrefs.  By referring to a string as though it was a
reference, he modified an unrelated variable.

>
> $ perl -le'
> use Data::Dumper;
> my %args;
> @{ $args{ owner } } = qw( hero wierd );

This sets $args{owner} to be a reference to an anonymous array
containing('hero', 'wierd');

> print Dumper \%args;
> $args{ owner } = q/sachin/;

This sets $args{owner} to be the string 'sachin';

> print Dumper \%args;
> @{ $args{ owner } } = qw( hero wierd );

This sets the array @sachin to contain ('hero', 'wierd');

It has nothing whatsoever to do with %args.


Paul Lalli


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


Reply via email to