Hi Joe
I got a bit lost amongst all those 'print' statements, but what you need to
know is this:
$current_field = 'school_id';
${$current_field} = 1234; # same as $school_id = 1234
HTH,
Rob
"Joe Mecklin" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> i'm building a routine in a module (ISD.pm) that will clear a list of
> variables (set them to ""), with the intent of expanding the
> functionality further in the future. when called, the sub is passed a
> list of strings that are variable names without the leading "$".
>
> my goal is to append the "$" to each string (school_id becomes
> $school_id, etc) then set $school_id = "".
>
> the expanded functionality is to allow a single argument to a sub be
> used as the variable name and the CGI param() argument since i tend to
> use the same name for each component.
>
> the call:
> &ISD::clear_input(FIELDS => "school_id, school_name, school_address");
>
> the sub:
> # CLEAR_INPUT
> # takes a list of variables (w/o the "$") to clear to an empty string
> sub clear_input
> {
> my %options = @_;
> my $fields = $options{FIELDS};
> my (@field) = split /, /, $fields;
>
> foreach my $current_field (@field)
> {
> my $field_name = "\$" . $current_field;
> my $field_value = \$field_name;
> print "\$current_field = .$current_field. : \$field_name =
> $field_name = ." . \$field_value . ". <br />";
> print "\$current_field = .$current_field. = ." . ${field_name}
> . ". <br />";
> }
> }
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]