Subject: | regexp captures not available in case body |
Subject: | broken_switch.pl |
#! /usr/bin/perl
use warnings;
use Switch;
$data = 'catch 22';
switch ($data) {
case qr/catch (\d+)/ {
print "I know my gross situation: $data\n";
print "My parsed situation is unknown: $1\n";
warn 'Matched, but not captured' unless defined $1;
}
else {
warn "$data is unrecognized\n";
}
}