This is happening because string interpolation (when /t is
turned into a tab) occurs when the scalar is loaded with
the string. The double-quotes, as you used in your program
cause interpolation to occur. Single quotes, reading data
from a file, etc. cause no interpolation to occur.
You have two possibilities:
- 1. translate the \t to a tab character. i.e. =~s/\\t/\t/g;
- 2. use an eval to force interpolation.
eval "\$f=qq/$_/";
print $f;