You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
895 B
Perl

#Using alternate with parentheses!
#!usr/bin/perl
use strict;
use warnings;
my $string1 = "hello";
my $string2 = "hello there";
my $string3 = "hi there";
print "$string1\n$string2\n$string3\n";
print "1: how are you?\n" if ( $string1 =~ m/(hello|hi) there/ );
print "2: how are you?\n" if ( $string2 =~ m/(hello|hi) there/ );
print "3: how are you?\n" if ( $string3 =~ m/(hello|hi) there/ );
#Using alternate without parentheses!
#!usr/bin/perl
use strict;
use warnings;
my $string1 = "hello";
my $string2 = "hello there";
my $string3 = "hi there";
print "$string1\n$string2\n$string3\n";
print "watch this:\n";
print "1: how are you?\n" if ( $string1 =~ m/hello|hi there/ );
print "2: how are you?\n" if ( $string2 =~ m/hello|hi there/ );
print "3: how are you?\n" if ( $string3 =~ m/hello|hi there/ );