Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Can we use print <<HTML; twice in same file?

by Perl300 (Friar)
on Aug 25, 2015 at 15:58 UTC ( [id://1139870]=note: print w/replies, xml ) Need Help??


in reply to [Solved]: Can we use print <<HTML; twice in same file?

Hi all, thanks for your inputs. I had tried removing # and everything after it preceding HTML (including ;) but it gives chunk of compilation errors first one being

Bareword found where operator expected at Admin_Test.pl line 54, near ""<table id="t01"

And when I add a ";" after "HTML" all the compilation errors disappear.

To correct those compilation errors I had added a semocolon after HTML. My aplologies for not mentioning this in original post

  • Comment on Re: Can we use print <<HTML; twice in same file?

Replies are listed 'Best First'.
Re^2: Can we use print <<HTML; twice in same file?
by fishmonger (Chaplain) on Aug 25, 2015 at 16:11 UTC

    You have a number of syntax errors. Lets look at the first few lines of your while loop.

    while (my \@row = $sth->fetchrow_array) { print "<table id="t01">"; print "<tr>"; if (row[0] eq '1') {

    my \@row is wrong. It should be my @row.
    print "<table id="t01">"; has a quoting error. You need to either escape the inner double quotes in id="t01" or use single quotes like this id='t01'.
    if (row[0] eq '1') is missing the $ on the $row[0] var

Re^2: Can we use print <<HTML; twice in same file?
by poj (Abbot) on Aug 25, 2015 at 16:28 UTC

    When I see a repeating pattern I think 'can I loop this ?'

    my @stat = ( ['trunk_usage' ,'% Trunk Usage'], ['pre_ivr' ,'Pre-IVR Call Volume'], ['trunk_group' ,'Trunk Group Utilization'], ['average_speed','Average Speed of Answer'], ['outage_call' ,'Outage Call Volume'], ['ivr_call' ,'IVR Call Volume'], ['non_outage' ,'Non-Outage Call Volume'], ['post_ivr' ,'Post-IVR Call Volume'],); my @row = (1,0,1,1,1,0,1,0); #while (my @row = $sth->fetchrow_array) { print qq!<table id="t01"><tr>!; for my $i (0..$#stat){ my $chk = ($row[$i] == 1) ? 'checked' : ''; print qq!<td> <input type="checkbox" name="$stat[$i][0]" value="1" $chk /> $stat[$i][1] </td>!; if (($i % 2) && ($i < $#stat)){ print q!</tr><tr>!; } } print q!</tr></table>!; #} print q!</div></body></html>!;
    You need to put the database stuff back to replace the test values in @row, and probably the <form> tags but around the table not each input.
    poj

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found