$str = 'pattern 2 [after] 123 abc DEX';
if ($str =~ m/^pattern\s+(\d+)\s+\[after\]\s+(.+)/) {
} else {
}
JHN0ciA9ICdwYXR0ZXJuIDIgW2FmdGVyXSAxMjMgYWJjIERFWCc7CgppZiAoJHN0ciA9fiBtL15wYXR0ZXJuXHMrKFxkKylccytcW2FmdGVyXF1ccysoLispLykgewogIHByaW50ICIkMVx0JDJcbiI7Cn0gZWxzZSB7CiAgcHJpbnQgIihubyBtYXRjaClcbiI7Cn0=