Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

(Ovid) Re: Stupid Program!

by Ovid (Cardinal)
on Nov 30, 2001 at 03:54 UTC ( #128508=note: print w/ replies, xml ) Need Help??

in reply to Program can't work on website; please examine code

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.


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

Comment on (Ovid) Re: Stupid Program!
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2015-11-27 08:04 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (720 votes), past polls