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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



japhy
Enthusiast

Dec 16, 2000, 10:31 PM


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

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


Code
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:


Code
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:


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

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