Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Perl script not rendering values

by oradba888 (Initiate)
on Nov 22, 2014 at 05:58 UTC ( [id://1108082]=perlquestion: print w/replies, xml ) Need Help??

oradba888 has asked for the wisdom of the Perl Monks concerning the following question:

I have a perl script that runs a form submission and sends me an email after user completes the form. Once I get the mail, i see the form fields BUT I do not see the values that the user would enter.

Here is a snippet:

print MAIL "...If Contractor, employed by: $FORM{'Contractor_Employer' +}\n"; print MAIL "...If Visitor, employed by: $FORM{'Visitor_Employer'}\n"; print MAIL "...If Reporting unsafe condition or other safety related i +ssue:\n"; print MAIL "$FORM{'Unsafe_Conditions'}\n"; print MAIL "\n"; print MAIL "IDENTIFICATION DETAILS\n"; print MAIL "...Full Name of Injured: $FORM{'NameInjured'}\n"; print MAIL "...Job Title: $FORM{'JobTitle'}\n"; print MAIL "...Date Hired: $FORM{'DateHired'}-$FORM{'DHMonth'}-$FORM{' +YearHired'} \n"; print MAIL "...Gender: $FORM{'Gender'}\n"; print MAIL "...Manager's Name: $FORM{'Emp_Manager ***************

any ideas?

Replies are listed 'Best First'.
Re: Perl script not rendering values
by davido (Cardinal) on Nov 22, 2014 at 07:53 UTC

    Since the snippet you posted shows only the print statements, does that mean you think the problem is that print MAIL .... is failing?

    If not, you've posted a snippet that doesn't include the part that's broken.


    Dave

Re: Perl script not rendering values
by rnewsham (Curate) on Nov 22, 2014 at 06:44 UTC

    Please use code tags around your code to make it readable.

    There is not enough code there to identify the problem. If the values you expect are not in %FORM as you seem to be indicating, I would recommend looking at where %FORM is populated from the POST data. If that is correct then look at the POST data and make sure the form is sending what you expect. You should look at Basic debugging checklist for tips on how to debug your code.

Re: Perl script not rendering values
by AnomalousMonk (Archbishop) on Nov 22, 2014 at 12:07 UTC

    This is OT the problem you've asked about in your OP, but whenever I see a gazillion
        print WHEREVER "... something \n";
    statements marching down the page, I think here-doc: see Quote and Quote-like Operators and especially at the end of Quote-Like Operators. E.g. (untested):

    print $filehandle <<END_OF_TEXT; ...If Contractor, employed by: $FORM{'Contractor_Employer'} ...If Visitor, employed by: $FORM{'Visitor_Employer'} and so on blank line(s) are easily included ...Gender: $FORM{'Gender'} ...Manager's Name: $FORM{'Emp_Manager'} END_OF_TEXT
    Note that scalars and arrays can interpolate. (This example also uses a lexical filehandle rather than a global filehandle: less chance for name collision.)

Re: Perl script not rendering values
by LanX (Saint) on Nov 22, 2014 at 12:59 UTC
    Additional to all the good advice you already got, please try to debug if %FORM is really populated ( I doubt)

    Something like

    use Data::Dumper; print MAIL "=== Check Form: \n", Dumper \%FORM, "\n=== end check\n" ;

    should do.

    Most likely you have a typo somewhere and forgot to switch on strict and warnings to catch them.

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1108082]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 01:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found