CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Frequently Asked Questions: Re: How Do I Read Data From A Form?: Edit Log


Dec 16, 2000, 10:31 PM

Views: 6573
Re: How Do I Read Data From A Form?

Function calls do not expand in quotes -- you need to do:

print "foo's value is ", param("foo"), "\n"; 

# or

$value = param("foo");
print "foo's value is $value\n";

Or, you can use the deref-array-ref trick, which creates a reference to an anonymous array, and then dereferences it inside a double-quoted string. I'll show it as a whole, and then break it down:

print "foo's value is @{[ param("foo") ]}\n";

The trick is that arrays are interpolated inside double quotes, and therefore, if you can put the stuff you want printed inside an array, then you can print it. And we can turn anything into an array by putting it inside a REFERENCE to an array, and then dereferencing it:

print "@{  # printing an array, and dereferencing... 
[ # a reference to an array...
param("foo") # containing this function's return value

Jeff "japhy" Pinyan -- accomplished hacker, teacher, lecturer, and author

(This post was edited by japhy on Dec 16, 2000, 9:43 PM)

This post has not been edited

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives