O'Reilly logo

Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP by Brent Ware, James Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required