http://www.perlmonks.org?node_id=1022252


in reply to Get variables from if with regex

In your particular case, it is not so hard to combine the regexes into one:
while (<IFILE>) { if (my ($word, $time_stamp) = /[#!]\s+(\w+)\s+(\d+)./) { print "[ $word $time_stamp ]\n"; } }
Note that the binding operator =~ imposes a scalar context on its left operand, so matching an array does not do what you think.
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ