Subject: | "redefined" warnings in Printer module |
I get a lot of "redefined" warnings. My Environment:
OS: Window 2000
Perl: 5.8.2
The module checks to load Unix driver or Win32 driver, but since the "BEGIN" blocks are executed at compile-time, it loads both Printer::Unix and Printer::Win32
The numbers at the beginning of each line is the line number of the
specified module.
Printer.pm
#---------------------------------------------------------#
61 BEGIN {
62 require Printer::Unix;
63 }
64 }
65
66
67 # load system specific modules for win32
68 BEGIN {
69 if ($OSNAME eq "MSWin32") {
70 # win32 specific modules
71 require Win32::Registry; # to list printers
72 require Win32;
73 require Printer::Win32;
74 }
75 }
must be
}
# load system specific modules for win32
BEGIN {
if ($OSNAME eq "MSWin32") {
# win32 specific modules
require Win32::Registry; # to list printers
require Win32;
require Printer::Win32;
} else {
require Printer::Unix;
}
}
#---------------------------------------------------------#
Also, in "Printer/Win32.pm"
62 my $register = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\$default";
triggers this warning: '"my" variable $register masks earlier declaration in same scope'
So, it must be
$register = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers\\$default";