We help IT Professionals succeed at work.

cgi perl script

netplus21
netplus21 asked
on
Hello,

I am trying to make modifications to a perl script in order to make it responsive to screen resolutions.

Here is an excerpt:

<tr>
<td colspan="2"></td>
<td colspan="2" style="color: #d00; text-align: left; font-weight: 700; line-height: 16px;"><!--ERROR--> </td>
</tr>			
<tr>				<td height="20" colspan="4"> </td>			</tr>
<tr>
<td colspan="2"></td>
<td colspan="4" style="text-align: left; padding-right: 0;"><font color="#c00000">*</font> Required fields</td>
</tr>			
<tr>				<td height="10" colspan="4"> </td>			</tr>
<!--NAME--><tr>
<!--NAME--><td class="txr"><!--FFN-->Name:</td>
<!--NAME--><td></td>
<!--NAME--><td class="txl"><input type="text" name="name" value=""><!--FN--> <font color="#c00000"><!--NAMER--></font></td>
<!--NAME--></tr>
<!--AGE--><tr>
<!--AGE--><td class="txr"><!--FAGE-->Age:</td>
<!--AGE-->	<td></td>
<!--AGE--><td class="txl"><input type="text" name="age" value=""><!--AGE--> <font color="#c00000"><!--AGER--></font></td>
<!--AGE--></tr>

Open in new window


I was under the impression that words enclosed in <!----> were simply comments. I found out that this wasn't the case, when I deleted <!--error-->, and the errors stopped showing up.

So therefore I assume that <!----> is for variables?

What could <!--NAME-->, <!--NAMER-->, <!--AGE-->, <!--AGER--> be doing? It doesn't seem to be making any difference at all when I remove them.

thanks for our help!
Comment
Watch Question

Your question and your code don't have anything to do with Perl.  That is html code and the parts you're referring to are html comment tags.

Author

Commented:
Hello,

Allow me to clarify further.

The above code is from a .txt file in a templates directory.

The '<!--error-->' tag produces actual errors, as mentioned in my previous post, it's not a comment tag.

Here is an instance of the '<!--error-->' tag in the main perl script.

open ( IN, "$template_path$page") or die $!;
				while ( <IN> )		{
					s/<!--Error-->/$message/;
					s/<!--MESSAGE-->/$message/;
					print $_;
				}
			close IN;

Open in new window


and also

s/<!--ERROR-->/ $message/ if $message;

Open in new window


and also

while ( <IN> )		{
				s/<!--Error-->/$message/;
				s/"><!--UN-->/$user_name">/ if $user_name;
				s/"><!--PW-->/$password">/ if $password;
				print $_;
			}

Open in new window



Here are some instances of '<!--NAME-->' and '<!--NAMER-->' that show up in the the main perl file, together with other sign up form tags.

while ( <IN> )		{
				next if /<!--NAME-->/ and $specs[0] eq 'no';
				next if /<!--AGE-->/ and $specs[1] eq 'no';
				next if /<!--GENDER-->/ and $specs[2] eq 'no';
				next if /<!--COUNTRY-->/ and $specs[3] eq 'no';
				next if /<!--CITY-->/ and $specs[4] eq 'no';
				next if /<!--NEWS-->/ and $specs[5] eq 'no';
				s/<!--NAMER-->/*/ if $specs[0] eq 'mandatory';
				s/<!--AGER-->/*/ if $specs[1] eq 'mandatory';
				s/<!--GENDERR-->/*/ if $specs[2] eq 'mandatory';
				s/<!--COUNTRYR-->/*/ if $specs[3] eq 'mandatory';
				s/<!--CITYR-->/*/ if $specs[4] eq 'mandatory';
				s/<!--NEWSR-->/*/ if $specs[5] eq 'mandatory';
				print $_;
			}

Open in new window


My question remains, whether it's alright, to remove tags similar to '<!--NAME-->', from the txt file, since they don't seem to be doing anything at all.
Most Valuable Expert 2014
Top Expert 2015
Commented:
If a perl script opens the txt file to <IN>
and executes
 while ( <IN> ){
				next if /<!--NAME-->/ and $specs[0] eq 'no';

Open in new window

then removing '<!--NAME-->' from the file can change what the perl script does.
especially if $specs[0] eq 'no'