On Jan 10, 2008 4:28 PM, ciwei <[EMAIL PROTECTED]> wrote:
>
> > push @{ $wwn{ "$host-$hba" } }, /^\s+WWN:\s+(1000[0-9a-fA-F]{12})$/;
>
> Thanks for the help.
>
> can you please explain in the above line , what the { } around
> push @{ $wwn ...  } <--here do ?
>
> is the { } here optional?  or can this be subsitute with ( )?
> thanks.

The answers are Sort of and no.  The {} in @{} is optional if it is
unambiguous:

my @array;
my $aref = [EMAIL PROTECTED];
my @new_array = @$aref; #no {} needed because $aref is unambiguous
my %hash;
$hash{key} = [EMAIL PROTECTED];
my @newer_array = @{$hash{key}}; #ambiguous, so {} is needed.

These are the same rules that control when you need to use ${var}:

my $foo = "bar";
print "${foo}bar\n"; #prints "barbar"
print "$foobar\n"; #either is a compiler error (with strict) or prints
nothing since there is no $foobar variable

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


Reply via email to