#!/usr/bin/perl
print "What is your name?";
$name = <STDIN>;
chop($name);
if ($name =~ /RANDAL/i) {
print "HELLO, RANDAL! HOW GOOD OF YOU TO BE HERE\n";
} else {
print "Hello, $name!\n";
}
This is the same code, except on line 5, we change the eq to =~ /RANDAL/i. This uses a Regular Expression to match the case. If you want to test your script type in RANDAL (in the same case as in the script, not randal, but RANDAL), and it will work fine for you.
!/usr/bin/perl
print "What is your name? ";
$name = <STDIN>;
CHOP($NAME);
IF ($NAME EQ "RANDAL") {
PRINT "HELLO, RANDAL! HOW GOOD OF YOU TO BE HERE!\n";
} ELSE {
PRINT "HELLO, $NAME!\N"; #ORDINARY GREETING
}
This code works fine, but when you get the prompt "What is your name?" type RANDAL and it will work correctly for you.
HTH
- f o o g o d
--- ruining the bell curve for everyone else --- |