| Next | Welcome to my ~/bin | 103 | 
 
        sub spool {
          if ($opt_s) {
            warn "(Not) spooling file\n" if $opt_v;
            return;
          }
          my $file = shift;
          my $spoolfile = make_spool_file_name();
          my $dotfile = $spoolfile;
          unless (copy($file, "$CONF{spooldir}/$dotfile")) {
            die "Sorry, couldn't spool $file: $!; aborting";
          }
copy is provided by File::Copy
We don't want printd to try to print the file before it is entirely copied
So we adopt a convention:
Files whose names begin with . are ignored by printd
Once the file is in place, the print renames it:
 
          unless (rename "$CONF{spooldir}/$dotfile",  
                         "$CONF{spooldir}/$spoolfile.$CONF{printable}") {
            die "Sorry, couldn't finish spooling $file: $!; aborting";
          }
          run_printd();
        }
| Next | Menu |  | Copyright © 2005 M. J. Dominus |