11.6. Handling Posted Data with %ARGS and <%args>

Mason handles posted form data similarly to Embperl. All form data widget names and their values are stored in the hash %ARGS. Let’s say a form is posted to a Mason page with the form widget named city. To obtain the value of the form widget, include this code in a Mason page:

<%perl> 
    my $city; 
    if (!exists $ARGS{´city´}) { 
        die "no value sent for required parameter ´city´"; 
    } else { 
        $city = $ARGS{´city´}); 
    } 
</%perl> 

Using this code, the my() variable $city contains the value posted in the form for the widget named city.

In practice, %ARGS is generally not used. Instead, Mason programmers use <%args> ... </%args>.

11.6.1. The <%args> ... </%args> Tag

The following tag, included anywhere in ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.