I’m maintaining some code that reads values over a serial radio and unpacks them into Perl data structures:
# Don't yell at me, I didn't write this
if ($command_string =~
/^.(.)(.).(..)(.)(..)(.)(....)(....)(....)(....)
(..)(..)(.)(.)(.)(.)(..)(..)(..)(..)(..)(..)(.)(.).......
(.)........(.)(.).*/sx) {
$config->{sequence} = hex(unpack('H2', $1));
$config->{radio_id} = hex(unpack('H2', $2));
...
$config->{radio_type} = hex(unpack('H2', $26));
$config->{radio_channel} = hex(unpack('H2', $27));
}
This unwieldy capturing regex made me wonder: what’s the upper bound on numbered capture variables in Perl? Does it go all the way up to $MAXINT?
This script works up to at least
$N=5000000. After that, it runs out of memory.