in reply to
error in printing output of Data::Dumper to file
It works for me (perl 5.14.3, Fedora 17 Linux.) The script should die if there is a permission problem preventing you from creating or writing to the file, so... have you double checked that it actually reaches the open and print statements in your second snippet?
It's often difficult to debug a script when only sections of it are posted; the bug is often a subtle interaction between the parts of the script that you are already suspicious of and the ones that are already known to be "correct."