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:

$ perl -le'
use Data::Dumper;
my %args;
@{ $args{ owner } } = qw( hero wierd );
print Dumper \%args;
$args{ owner } = q/sachin/;
print Dumper \%args;
@{ $args{ owner } } = qw( hero wierd );
print Dumper \%args;
'
$VAR1 = {
          'owner' => [
                       'hero',
                       'wierd'
                     ]
        };

$VAR1 = {
          'owner' => 'sachin'
        };

$VAR1 = {
          'owner' => 'sachin'
        };

It would work if you assigned the anonymous array directly:

$ perl -le'
use Data::Dumper;
my %args;
$args{ owner } = [ qw( hero wierd ) ];
print Dumper \%args;
$args{ owner } = q/sachin/;
print Dumper \%args;
$args{ owner } = [ qw( hero wierd ) ];
print Dumper \%args;
'
$VAR1 = {
          'owner' => [
                       'hero',
                       'wierd'
                     ]
        };

$VAR1 = {
          'owner' => 'sachin'
        };

$VAR1 = {
          'owner' => [
                       'hero',
                       'wierd'
                     ]
        };



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

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


Reply via email to