Error message is stored in $!
#!/usr/bin/perl -w use strict; open(FH, '<', 'yourFileName.dat') or die $!; print "goodopen.dat opened successfully\n"; close FH;