$_ = 'foo\$bar'; { if(m/\G((?:\\\$|\$)\w+)/gc or m/\G(\w+)/gc) { print "token: '$1'\n"; redo; } }