?
Solved

How to not print blank_fields?

Posted on 2003-02-24
4
Medium Priority
?
162 Views
Last Modified: 2013-12-25
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
Comment
Question by:jamaica
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
Tintin earned 400 total points
ID: 8012343
The easiest way is to do something like:

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

0
 
LVL 2

Expert Comment

by:BassTeQ
ID: 8013473
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
 
LVL 48

Expert Comment

by:Tintin
ID: 8013902
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
 

Author Comment

by:jamaica
ID: 8085529
Tintin, thank you!!

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

Featured Post

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question