my $pl = ""; open(TXT, ") { s/\./->/; s/=/=>/; s/"/'/g; s/\s+End With/);/; s/\s+With (\w+)->(\w+)/\$Range = \$$1->$2;\nwith (\$Range/i; s/(.*[^;])\n/$1,\n/; $pl .= $_; } close(TXT); open(TXT, ">mymacro.pl"); print TXT $pl; close(TXT);