Ok, I'm trying to write a perl program to do somewhat carefree web updates for me. I basically run a script and it asks me for text, and image names, and makes an update for me without having to touch any HTML (which makes me a happy guy) But, Perl seems to be having some trouble with my code. Any takers? I get the error Can't modify <HANDLE> in scalar assignment at ./webpage.pl line 103, near "$name1)" which is in the first if statement of the makeTable subroutine. I'm really itching to get this working as I think I'm very close. My problem may be how I'm dealing with backslashes from HTML refs with my scalar names, I'm not sure. I'm fairly new to Perl and don't know it's subtleties yet. Code is below. Thanks for the help, Adam
print "Do you have any images? "; chomp($image_answer = <STDIN>); if($image_answer eq "yes" || $image_answer eq "y") { print "How many? (1-4) "; chomp($numPics = <STDIN>); &makeTable($numPics); } elsif($image_answer eq "no" || $image_answer eq "n") {print "No soup for you!\n";} sub makeTable { if($numPics==1){ print NEWCONTENT "<TABLE><TR><TD>"; print "Name of image 1: "; chomp(<STDIN>=$name1); print NEWCONTENT "<IMG SRC=pics/$name1></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/spacer.gif></TD</TR> \n"; print NEWCONTENT "</TABLE>"; print "Table for 1 created"; } elsif(numPics==2){ print NEWCONTENT "<TABLE><TR><TD>"; print "Name of image 1: "; chomp(<STDIN>=$name1); print "Name of image 2: "; chomp(<STDIN>=$name2); print NEWCONTENT "<IMG SRC=pics/$name1></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/$name2></TD></TR> \n"; print NEWCONTENT "</TABLE>"; print "Table for 2 created"; } elsif(numPics==3){ print NEWCONTENT "<TABLE><TR><TD>"; print "Name of image 1: "; chomp(<STDIN>=$name1); print "Name of image 2: "; chomp(<STDIN>=$name2); print "Name of image 3: "; chomp(<STDIN>=$name3); print NEWCONTENT "<IMG SRC=pics/$name1></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/$name2></TD></TR> \n"; print NEWCONTENT "<TR><TD><IMG SRC=pics/$name3></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/spacer.gif></TD</TR> \n"; print NEWCONTENT "</TABLE>"; print "Table for 3 created"; } elsif(numPics==4){ print NEWCONTENT "<TABLE><TR><TD>"; print "Name of image 1: "; chomp(<STDIN>=$name1); print "Name of image 2: "; chomp(<STDIN>=$name2); print "Name of image 3: "; chomp(<STDIN>=$name3); print "Name of image 4: "; chomp(<STDIN>=$name4); print NEWCONTENT "<IMG SRC=pics/$name1></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/$name2></TD></TR> \n"; print NEWCONTENT "<TR><TD><IMG SRC=pics/$name3></TD>"; print NEWCONTENT "<TD><IMG SRC=pics/$name4></TD</TR> \n"; print NEWCONTENT "</TABLE>"; print "Table for 4 created"; } else print "Number entered is not within accepted paramters. \n"; }

In reply to HTML and Perl by Kones

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.