Jürgen Exner said:
Had you enabled warnings then perl would have told you:
Use of uninitialized value in concatenation (.) or string at ....
In short: You do not have a variable that is named
form_data{'test'}
Besides that what you are trying to do is known as symbolic references and
it is A BAD IDEA!
See the FAQ "How can I use a variable as a variable name?" for details about
why and what to use instead.
jue
I looked at the faq, but did not really see anything applicable. Here
is the deal. I have been notified that I have clean up all my variables
that print to not allow any <, >, ', &, ( or ) in them to prevent cross
platform scripting hacking. So I have a confirmation page that prints
dozens of variables that are global variables, most of which are form
variables from the form input. So I wanted to have a list of the
variable names, and use one small section of code to do the
substitutions, like this:
foreach my $variable
(customer_number,"form_data{'Ecom_BillTo_Postal_Name_First'}","form_data{'Ecom_BillTo_Postal_Name_Last'}",
"form_data{'Ecom_BillTo_Company'}","form_data{'Ecom_BillTo_Postal_Street_Line1'}","form_data{'Ecom_BillTo_Postal_City'}",
"form_data{'Ecom_BillTo_Postal_StateProv'}","form_data{'Ecom_BillTo_PostalCode'}","bill_country,form_data{'Ecom_BillTo_Telecom_Phon
"form_data{'Ecom_BillT
nline_Email'}","form_data{'Ecom_ShipTo_Postal_Name_First'}","form_data{'Ecom_ShipTo_Postal_Name_Last'}",
"form_data{'Ecom_ShipTo_Postal_Street_Line1'}","form_data{'Ecom_ShipTo_Postal_City'}","ship_country","form_data{'PO'}",
"$form_data{'Comments'}") {
$$variable =~ s/\</\</g;
$$variable =~ s/\>/\>/g;
$$variable =~ s/\(/\(/g;
$$variable =~ s/\)/\)/g;
$$variable =~ s/\'/\'/g;
}
If I inline it, I end up with 5*18 or 90 lines of code in what should be
able to be done in 6 or 7.
Thanks,
Marshall