[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-AnyPerl] substituting variables into objects



Adam Witney wrote:
> 
> i want to be able to use something like this....
> 
> my $field = 'textfield';
> my $options = q{'fieldname','default text',15,15};
> 
> print $cgi->$field($options);
> 
> this doesn't work....puts the whole contents of the $options into the name
> field of the textfield
> 
> anyone have any ideas how i could do this?
> 

I'm assuming that you are reading in the string
q{'fieldname','default text',15,15}
from a file...

In which case you want to leave off the single quotes when you create that
file, and after reading in the line of text split it on commas:

my $options = 'fieldname,default text,15,15';
my @options = split /,/, $options;

print $cgi->$field(@options);


HTH

Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org