Hi,
Mason is just Perl code itself, so you should be able to do anything Perl in it.

The syntax ${$a} is a way of "de-referencing" $a in Perl.  This particular example you gave would be an attempt to dereference as a Scalar, the reference stored in $a.  From the error description you gave, it seems that $a is just a Scalar already ("fullname"), and not a reference to a Scalar.  So, you should be able to do anything like the following in Mason:

$var_name = 'fullname';
$ref = \$var_name;
print (${$ref});       #  of course don't use print() in Mason

should print out the string:
   fullname

Basically,  $var_name == ${$ref}.

And just a word of advice, try to always `use strict;` if at all possible.

- Jeff


----- Original Message ----
From: Karjala <[EMAIL PROTECTED]>
To: Mason List <[email protected]>
Sent: Saturday, March 11, 2006 2:49:03 PM
Subject: [Mason] ${$a}

Hi.

I was wondering whether there's a way in Mason to use "references" (I don't know what they're called) of the type ${'address'} or ${$a}where $a holds a scalar, the name of a variable.

I need this to do form validation with fewer lines of code.

Right now I'm getting this Mason error: Can't use string ("fullname") as a SCALAR ref while "strict refs" in use at...

Is it not possible?

Thanks,
- Karj

Reply via email to