in reply to Constant variables
The logic of the sample is not good for a real CGI but the technique itself works great and I get to show the serial comma function again. :)
#!/usr/bin/perl #========================================================= use warnings; use strict; use CGI qw(:standard); #========================================================= print header(), start_html(), start_form(); my @param_names = qw( title address description ); my @missing = grep { not param($_) } @param_names; if ( param('submitted') and @missing ) { print "Please fill in: ", i({-style=>'color:#A00;'}, serial(@missing) . '.' ); } for my $field ( @param_names ) { print p( b($field), textfield(-name => $field ) ); } print submit(-name=>'submitted'); print end_form(), end_html(); exit 0; #========================================================= sub serial { join(', ', @_[0..$#_-1]) . (@_>2 ? ',':'' ) . (@_>1 ? (' and ' . $_[-1]) : $_[-1]); }
|
|---|