in reply to Path to another server

open (TOT_TXT, '>$tot_file') || die "$tot_file open failed: $!";
The single quotes prevent interpolation of the $tot_file variable. This opens a file whose name is literally $tot_file, instead of the contents of the variable. Try this:
open (TOT_TXT, '>', $tot_file) || die "$tot_file open failed: $!";