#!/usr/bin/perl
# w2.4.pl -- Perl strings

#comparison

$x = one;
$y = bell;
$z = bell;

if ($x eq $y) {print("1) one eq bell\n");} else {print("1) one ne bell\n");}
if ($z eq $y) {print("2) bell eq bell\n");} else {print("2) bell ne bell\n");}

if ($x ne $y) {print("3) one ne bell\n");} else {print("3) one eq bell\n");}
if ($z ne $y) {print("4) one eq bell\n");} else {print("4) bell eq bell\n");}

if ($x lt $y) {print("3) one lt bell\n");} else {print("3) one gt bell\n");}
if ($z ne $y) {print("4) bell lt bell\n");} else {print("4) bell eq bell\n");}


# chop() and chomp()

$z= "disestablishmentarianism";
print ("\$z assigned $z\n\n"); 

chop ($z);
print ("\$z after chop(\$z) yields:  $z\n");
chop ($z);
print ("\$z after chop(\$z) yields:  $z\n");
chop ($z);
print ("\$z after chop(\$z) yields:  $z\n");

print ("\n");

$z= "$z" . "\n\n";			#add newline
print ("$z$z\n");

chomp ($z);				#remove newline
print ("After chomp(\$z), \$z\$z is $z$z\n");

chomp ($z);				#chomp removes only space
print ("After chomp(\$z) again,  \$z\$z is $z$z\n");

__END__

