in reply to How do I write to a file?

A good idea when writing to a file is to include a space between the filename and the direction symbol. Like this:

open(FH, "> sample.txt") or die("Cannot write to file: $!\n");

Perl will ignore the extra space between the '>' and the filename. It is useful in preventing unexpected results.
-DigitalKitty