David,
I the reason this worked for Scot and not you is something that is
both simple and EASILY OVERLOOKED. Consider the lines.
#Scot
if ($_ == 1) {
^^---> Scot is using a comparison operator
#David
if ($_[0]=1) {
^--> You are using an assignment operator.
So in ef
:
: < DO STUFF>
Comments in perl begin with #, not <
Perl probably thinks you're referring to a
file handle in angle brackets.
Sorry, this is me using my own shorthand, everything is correctly #'d
in the code.
: sub error {
:
:
:
: if ($_[0]=1) {
'=' is an assignment operator. You
david Greenhalgh <[EMAIL PROTECTED]> asked:
:
: Been banging my head on this, I'm obviously missing
: something obvious, but I can't see what. Would someone
: put me out of my misery?
:
: My code checks the value of a variable $status.
: $status can have three values, 0,1,2. 0 is good, 1
: and 2
This worked for me.
#!/usr/bin/perl -w
use strict;
use CGI;
my $cgi = new CGI;
print $cgi->header(-title=>'Hi there');
print $cgi->h3('What\'s up');
print qq(\n);
my $status = 0;
my $i = 0;
for($i=0; $i<3; $i++) {
if($status) {
error($status);
}
$status++;
}
sub error {
print $cgi->p