open (ki_file, ">ki_file.txt") or die ("\n\nCould not open file. $!\n\n"); # Open file to dump ki_token from table print "\n ki_file.txt opened for output\n"; undef $/; # Undefining end of record character $stmt = "SELECT ki from imsi_period where imsi_id=346 "; # ki is field, containing encrypted data $sth = $dbh->prepare($stmt); $sth->{ChopBlanks} = 1; $sth->execute(); $sth->bind_col(1,\$ki_token,{TYPE => SQL_CHAR}); while ($sth->fetch) { # print $ki_token; print ki_file ($ki_token); print "Ki_Token is written to ki_file.txt." } $/ = "\n"; # Restore end of record character for normal behaviour later close (ki_file); # Close file ......