________ $1 unconditionally refers to this capture
/ if the match was successful.
|
| __ $2 unconditionally refers to this capture
| / if the match was successful.
| |
v v
/(...)|(...)/
####
for (qw(a b)) {
/(a)|(b)/;
print(
defined($1) ? $1 : '~',
defined($2) ? $2 : '~',
"\n"
);
}
####
a~
~b