catfish1116 has asked for the wisdom of the Perl Monks concerning the following question:
I am working on the match functionality and have come up with a problem. Below is code and error:
print "Enter a string: "; chomp(my $_ = <STDIN>); if ($_ = /([A|a])/) { my $afterstring = $'; print "This is the after string $afterstring\n"; if( $afterstring = /([B|b)/ ) { print The string has an a but also a following b\n"; } else { print "The string has an a , but not a following b\n"; } } else { print "String did not match\n"; }
And here is the error:
Uncaught exception from user code Unmatched [ in regex; marked by <-- HERE in m/([ <-- HERE B|b) +/ at Exercise_7_4.pl line 24.
TIA The Catfish
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: match function
by Corion (Patriarch) on Jun 09, 2020 at 19:01 UTC | |
Re: match function
by choroba (Cardinal) on Jun 09, 2020 at 20:41 UTC | |
Re: match function
by BillKSmith (Monsignor) on Jun 09, 2020 at 22:50 UTC | |
Re: match function
by AnomalousMonk (Archbishop) on Jun 09, 2020 at 21:57 UTC | |
Re: match function
by Marshall (Canon) on Jun 10, 2020 at 20:13 UTC | |
by AnomalousMonk (Archbishop) on Jun 10, 2020 at 22:20 UTC |