my $pattern = qr{ # quoted regex HOSTNAME: # Literal text \s* # 0 or more whitespace (?:\d{4}-)? # Some devices begin with the router model \Q$hostname_for_regex\E # Router hostname (grbr-rwan-x) \s+ # 1 or more whitespace GRBR: # Literal text \s* # 0 or more whitespace \Q$dev_ref->{grbr}\E # Just the GRBR }ixms;