7.4. Making Perl Report Filenames in ErrorsProblemYour program works with files, but Perl's errors and warnings only report the last used filehandle, not the name of the file. SolutionUse the filename as the filehandle: open($path, "< $path") or die "Couldn't open $path for reading : $!\n"; DiscussionOrdinarily, error messages say:
The filehandle LOG doesn't help much because you don't know which file the handle was connected to. By using the filename itself as indirect filehandle, Perl produces more informative errors and warnings:
Unfortunately, this doesn't work with See Also
Recipe 7.1
; the Copyright © 2001 O'Reilly & Associates. All rights reserved. |
|