NAME Printer.pm - low-level, platform independent printing (curently Linux and MS Win32. UNIX should also work.) SYNOPSIS use Printer; $prn = new Printer('lp'); @available_printers = $prn->list_printers; $prn->use_default; $prn->{'printer'} = 'foo'; $prn->print($data); DESCRIPTION A low-level cross-platform interface to system printers. This module is intended to allow perl programs to use and query printers on any computer system capable of running perl. The intention of this module is for a program to be able to use the printer without having to know which operating system is being used. USAGE Open a printer handle $printer = new Printer('osname' => 'printer port'); $printer = new Printer('MSWin32' => 'LPT1', 'Linux' => 'lp'); This method takes a hash to set the printer name to be used for each operating system that this module is to be used on (the hash keys are the values of $^O or $OSNAME for each platform) and returns a printer handle which is used by the other methods. Select the default printer $printer->use_default; =head3 Linux The default printer is read from the environment variables $PRINTER, $LPDEST, $NPRINTER, $NGPRINTER in that order, or is set to "lp" if these variables are not defined. =head3 Win32 THe default printer is read from the registry (trust me, this works). List available printers %hash = $printer->list_printers. This returns a hash of arrays listing all available printers. The hash keys are: =over 4 =item * %hash{names} - printer names =item * %hash{ports} - printer ports =back Print $printer->print($data); Print a scalar value onto the print server through a pipe (like Linux) List queued jobs @jobs = $printer->list_jobs; =head3 Linux Each cell of the array returned is an entire line from the system's lpq command. =head3 Windows The array returned is empty (for compatibility). =head3 Warning This method will probably return a hash in future when I've figured out how to access the print queue on windows. BUGS List_jobs needs writing for win32 TESTED PLATFORMS This module has been tested under Linux, Windows NT4 and Windows 95. Testers and developers are wanted for all other platforms. AUTHOR Stephen Patterson TODO Make printer name a $OSNAME keyed hash. Make list_queue work on windows.