Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Ignoring the HERE doc, try this:

#!/usr/bin/perl use strict; use CGI; my $page = new CGI; my $value = $page->param("Comic"); ##########declare the names of the files for the loop my @Comm = qw( Images/Le_Comic.jpg Images/Le_Comic2.jpg Images/Le_Comic3.jpg Images/Le_Comic4.jpg Images/Le_Comic5.jpg Images/Le_Comic6.jpg Images/Le_Comic7.jpg Images/Le_Comic8.jpg Images/Le_Comic9.jpg Images/Le_Comic10.jpg Images/Le_Comic11.jpg Images/Le_Comic12.jpg Images/Thanksgiving_Comic.jpg ); #Open up the comments file my $file = '../comment.txt'; open FILE, "< $file" or die "Cannot open $file for reading"; my @Comment = <FILE>; close(FILE); my ( $Como, $Number); #do a "for" loop to make it choose the quote for my $i ( 0 .. $#Comment ) { if ($value eq $Comm[$i]) { $Como = $Comment[$i]; $Number = $i + 1; last; } }

Your biggest problem was this line:

my ('$i','$Como','$Number');

Don't declare variables by putting them in single quotes. This may not fix your problem, but at least the program should run.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.


In reply to (Ovid) Re: Stupid Program! by Ovid
in thread Program can't work on website; please examine code by Anonymous Monk

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (15)
    As of 2014-10-23 14:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      For retirement, I am banking on:










      Results (125 votes), past polls