Click to See Complete Forum and Search --> : Why isnt this working PERL+HTML (Newbie)?


digital_storm
05-11-2005, 09:21 AM
Hello

I have a class called Status which has get methods to return values of current object.
I know that the parameters in my object are set. Some parameters are set from a web formular and if any parameter are set in the wrong way the form should be displayed again with current value (i.e not the one which was printed but the one that was stored in my object) So I have done like this in my html form:
print <<END_HTML
.
.
<input name="m1nr2" type="text" id="m1nr2" value="$status->getcfimm()">
.
.
END_HTML
where $status has been declared as my $status=new Status(); and getcfimm() is a method in $status that returns a value.

But this is just returning Status->getcfimm() as if I would have done printf('Status->getcfimm()');

What should I do to get this to work?

/D_S

Nedals
05-11-2005, 07:46 PM
$status->getcfimm() will not interpolate within a here-is document. You need to get the value outside the here-is doc.

my $value = $status->getcfimm();
print <<END_HTML;
..
...... value="$value">
...
END_HTML

Charles
05-11-2005, 09:34 PM
Or, if you are using the ubiquitous CGI.pm module:#!c:\perl\bin\perl.exe

use CGI qw(:cgi :html :form);

param (m1nr2=>$status->getcfimm());

print header,
start_html,
start_form,
label ('foo', textfield (-name=>'m1nr2', -id=>'m1nr2')),
end_form,
end_html;

digital_storm
05-12-2005, 02:09 AM
Thanks you all very much! :-) :-)