• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

How to not print blank_fields?

I'm trying to set a command that will not print blank fields in my form's emailed results.

Let's say I have my check_email entries. If no value was entered for the field 'Version', I do not want to have the field 'Version' printed out in the email results.

How's the best way to have a no_blank_field_print set in the cgi script?

open CREATE_EMAIL, ">

print CREATE_EMAIL "\nVersion = $in{'Version'}";

print CREATE_EMAIL "\nType = $in{'Type'}\n";

close CREATE_EMAIL
0
jamaica
Asked:
jamaica
  • 2
1 Solution
 
TintinCommented:
The easiest way is to do something like:

print "some $variable\n" if $variable;

0
 
BassTeQCommented:
As Tintin has said above


print CREATE_EMAIL "\nVersion = $in{'Version'}" if ($in{'Version'});

print CREATE_EMAIL "\nType = $in{'Type'}\n" if ($in{'Type'});

0
 
TintinCommented:
I would also point out on a related topic that it appears jamaica is using cgi-lib.

This library is old, outdated and not maintained.

Start using the standard CGI.pm module.
0
 
jamaicaAuthor Commented:
Tintin, thank you!!

Yes, I'm using cgi-lib and will certainly look into upgrading to CGI.pm.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now