From:                   "HENRY,MARK (HP-Roseville,ex1)" <[EMAIL PROTECTED]>
> I'm passing a few variables into a function, and I want to be hip so I
> send them in as references..
> 
> my_function (\$var_1, \$var_2);
> 
> Now, within the function, can I dereference them immediately?  I've
> assigning them to intermediate scalars first, which works, but I want
> to cut out the middle man..
> 
> works:
> 
> --
> sub my_function {
> 
> my $var_1_ref=$_[0];
> my $var_2_ref=$_[1];
> 
> print "var 1 is $$var_1 and 2 is $$var_2";
> --
> 
> I want to be able to do something like..
> 
> --
> print "var 1 is $$_[0] and 2 is $$_[1]";
> --

print "var 1 is ${$_[0]} and 2 is ${$_[1]}";

The reason is 
        $$_[0]
is the same as
        ${$_}[0]
This means ... dereference the array reference stored in $_ and 
access the first element.

While what you want is "give me the first element of @_ and 
dereference the scalar reference stored in it".

HTH, Jenda

===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to