Scalar and Text Basics
Regex Match
A match operator checks whether a scalar follows a small text pattern.
Regex Match
regex_match.pl
use strict;
use warnings;
my $code = ;
my $matched = $code =~ /^([A-Z]+)-(\d+)$/;
my $matched_text = $matched ? "yes" : "no";
my $prefix = $matched ? $1 : "none";
my $number = $matched ? $2 : "none";
print "code=$code\n";
print "matched=$matched_text\n";
print "prefix=$prefix\n";
print "number=$number\n";
use strict;
use warnings;
my $code = ;
my $matched = $code =~ /^([A-Z]+)-(\d+)$/;
my $matched_text = $matched ? "yes" : "no";
my $prefix = $matched ? $1 : "none";
my $number = $matched ? $2 : "none";
print "code=$code\n";
print "matched=$matched_text\n";
print "prefix=$prefix\n";
print "number=$number\n";
use strict;
use warnings;
my $code = ;
my $matched = $code =~ /^([A-Z]+)-(\d+)$/;
my $matched_text = $matched ? "yes" : "no";
my $prefix = $matched ? $1 : "none";
my $number = $matched ? $2 : "none";
print "code=$code\n";
print "matched=$matched_text\n";
print "prefix=$prefix\n";
print "number=$number\n";
regex match
A regex match returns true when text fits the pattern.