Date: Tue, 11 Nov 2003 21:11:01 +0000 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Darryl Hoar <darryl@osborne-ind.com> Cc: freebsd-questions@freebsd.org Subject: Re: OT - Perl Question Message-ID: <20031111211101.GA4434@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <008001c3a896$5cda7f90$0701a8c0@darryl> References: <008001c3a896$5cda7f90$0701a8c0@darryl>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Tue, Nov 11, 2003 at 02:57:04PM -0600, Darryl Hoar wrote:
> I am trying to learn perl. I am going through a tutorial and have come
> across a syntax error I can't figure out.
>
> Here's the code:
>
> print "Please tell me your name: ";
> chop ($name=<STDIN>);
>
> print "Please tell me your nationality: ";
> chop ($nation=<STDIN>);
>
> if ( $nation eq "British" or $nation eq "New Zealand" )
> {
> print "Hallo $name, pleased to meet you!\n";
>
> }
>
> when I try to run it, it generates a compile errors on the
> if line.
>
> I know its the conditional test, but don't know how to fix
> it to be syntactically correct in perl.
>
> Any help?
Works fine if you ask me:
happy-idiot-talk:/tmp:% cat > foo.pl
#!/usr/bin/perl -w
print "Please tell me your name: ";
chop ($name=<STDIN>);
print "Please tell me your nationality: ";
chop ($nation=<STDIN>);
if ( $nation eq "British" or $nation eq "New Zealand" )
{
print "Hallo $name, pleased to meet you!\n";
}
happy-idiot-talk:/tmp:% perl -cw foo.pl
foo.pl syntax OK
happy-idiot-talk:/tmp:% chmod +x foo.pl
happy-idiot-talk:/tmp:% ./foo.pl
Please tell me your name: Matthew
Please tell me your nationality: British
Hallo Matthew, pleased to meet you!
There was probably a typo in your original script which you've managed
to inadvertently fix when you copied your code into the e-mail.
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)
iD8DBQE/sVBldtESqEQa7a0RAruOAKCDfDPh7kF8QP3cYg8V1yl8k0Py5QCfVEag
kS5Vj+PfHpG6zDszcN/dMrE=
=GGvz
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031111211101.GA4434>
