#!/usr/bin/perl use CGI qw/:standard/; print header; $form_field = param("form_field"); # get the value from form if ($form_field eq ""){ # if value is nothing &print_error; # run subroutine }else{ # else print "$form_field\n"; # do your stuff } sub print_error{ # Error subroutine print "there was an error\n"; }