in reply to Accessing a file from the perl
unless (open (USERNAME, "username")) { print "ERROR:Cannot open username file.\n"; exit(1); # ERROR }
Just a parenthetic note: The code quoted above is more idiomatically (and, IMHO, better) written as below, which uses both a lexical filehandle and the three-argument form of open. (See also perlopentut.)
my $filename = 'foo'; open my $filehandle, '<', $filename or die "opening '$filename': $!";
|
|---|