param
function:
$name = $query->param( 'name' );the variable
$name
contains “mon” from the web input:
<input type="text" size="32" name="name" value="mon">For details, check Perl CGI web-related module.
~wenchen/public_html/cgi-bin/351/week3/CGIDemo.pl |
#!/usr/bin/perl use CGI; $query = new CGI; $act = $query->param( 'act' ); $name = $query->param( 'name' ); if ( $act eq "Submit" ) { # Remove leading and trailing spaces. $name =~ s/^\s*(\S*)\s*$/$1/; # For security, remove some Unix metacharacters. $name =~ s/;|>|>>|<|\*|\?|\&|\|//g; # For concurrency control, exclusively lock a dummy file. open ( fh, "> dummy.txt" ); flock ( fh, 2 ); system( "./CGIDemo '$name'" ); close ( fh ); } elsif ( $act eq "Help" ) { system( "/bin/cat Help.html" ); } |