Thanks for all the replies, I'll use the strict and warning commands.
Basically I made a copy of the sub routine and changed the code to just print the 2 submit buttons, the original sub routine was being called in 4 different locations
so I changed one of the locations based on the logic to use the new copied sub-routine.
Also I realised that variable wasn't being recognized in the sub routine as I had defined it at a lower place in the control.

Thanks Everybody

Newbie to PERL/CGI - the people who wrote this are long gone, only
have o'reilly-Learing Perl and Elizabeth Castro perl & the CGI 2nd ed

I have altered a sub routine in a CGI script to add a submit button on data displayed in table format, see attachment.
This new button(CONTRACT) should only be displayed after the 1st 2 buttons(MODIFY and DELETE). However it appears after the 2nd set of submit
buttons also.
I have tried passing additional variables to the sub routine and they are always blank, there are 2 things that I don't understand(probably more, but don't know enough) Here is the code for the sub routine.

1) On line 238 it references a sub routine in a library what does this do, I have included this sub routine also.

2) On line 250 it references a variable $prtupd, it never passes this to the sub routine yet it contains the value it sets in the main module, when I
try to pass a variable by adding it to line 236 and in the line in the main module it is always empty(lines 247 and 248 confirms this for me)

"==" is a numeric operator, but you are checking a string value "YES" so you want to use "eq" instead of "==":

if (($prntcontracts eq "YES") && ($prtupd == 1))

change that and see if it resolves the two button problem.

KevinADC

04-27-2009, 10:10 PM

this is just an html comment:

print "<!--html-lib.pl::PrintRow-->\n";

it does nothing as far as the program is concerned. Not sure why it is there in the html code output. The code you posted is calling the PrintSal subroutine, not the PrintRow subroutine. Which is what the html comment above is indicating for some unknown reason.

Judging by thte code you posted, the author was not a good perl programmer. The code indicates a fundamental lack of writing good perl programs. It might work but is a potential can of worms.

oesxyl

04-27-2009, 10:32 PM

this is just an html comment:

print "<!--html-lib.pl::PrintRow-->\n";

it does nothing as far as the program is concerned. Not sure why it is there in the html code output.
I guess it use SSI, :)

best regards

KevinADC

04-27-2009, 11:47 PM

I guess it use SSI, :)

best regards

that is not a valid SSI tag and while it is possible to use SSI and script generated output its something you rarely see. Maybe there is something else going on that we are unaware of.

bazz

04-28-2009, 02:02 AM

Can I chip in first (FishMonger). lol

You really need to make sure that your script starts with the strict pragma.

use strict;

Your sub, in the second code section doesn;t declare the vars as it should.

also, make sure you have warnings outputted to the browser or your server error logs.

use warnings; # at top of script

But, also, you might want to read up on the CGI module since it could make your script shorter and easier to use.

hth

bazz

FishMonger

04-28-2009, 05:19 AM

make sure you have warnings outputted to the browser or your server error logs.

use warnings; # at top of script

You forgot something.

use warnings;
use CGI::Carp qw<fatalsToBrowser warningsToBrowser>; # this outputs the errors to the browser, but the warnings needs 1 more step.
After outputing the html header, you add this line which will output the warnings as html comments.

warningsToBrowser(1);

The script is using depreciated html code which would be better handled with the use of css.

Rather than outputting raw html, I'd use HTML::Template. http://search.cpan.org/~samtregar/HTML-Template-2.9/Template.pm