If you're looking to do form validation in a mason component and looping through a set of fields, just use the %ARGS hash:
<%init>
my @required_fields = qw(field1 field2)
my @errors;
foreach my $k( @required_fields ){
if( $ARGS{$k} =~ s/^\s*$/ ){
push(@errors,"$k required");
}
}
if( @errors ){
return $m->comp('required_field_error.mas', fields => [EMAIL PROTECTED] );
}
</%init>
I may be wrong but the tone of the e-mail makes it sound like you're relatively new at Perl and Mason. If that's the case, Randal's statements that you don't want to do this are true. For something as simple as form validation, there's no reason decrease security or legibility by using symbolic references in this way.
Brian
On 3/11/06, Karjala <[EMAIL PROTECTED]> wrote:
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

