in reply to Tab Stop Converter

Does this code do the same, if the value for $ts is set appropriately?
perl -p -i.bak -e '$ts=12; while (m/\t/g) { $d= ($ts - (pos % $ts)) % $ts + 1; $x = " " x $d; s/\t/$x/; }' filename.txt

(I know the -i.bak will create a backup file, but I tend to do that at least until I'm sure I have a replacement working...)