diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-05-19 14:14:22 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-05-19 14:14:22 +0000 |
commit | 78dd1c5b452725709f60ea017882031a4cab38e5 (patch) | |
tree | 8d17ee5946d711cf4e55ecc7123b6c04c1f773e9 /perl-install/printer | |
parent | b6c81a431dc681db51eaf22eaf090c280b56d9f4 (diff) | |
download | drakx-backup-do-not-use-78dd1c5b452725709f60ea017882031a4cab38e5.tar drakx-backup-do-not-use-78dd1c5b452725709f60ea017882031a4cab38e5.tar.gz drakx-backup-do-not-use-78dd1c5b452725709f60ea017882031a4cab38e5.tar.bz2 drakx-backup-do-not-use-78dd1c5b452725709f60ea017882031a4cab38e5.tar.xz drakx-backup-do-not-use-78dd1c5b452725709f60ea017882031a4cab38e5.zip |
perl_checker fixes
Diffstat (limited to 'perl-install/printer')
-rw-r--r-- | perl-install/printer/cups.pm | 2 | ||||
-rw-r--r-- | perl-install/printer/default.pm | 2 | ||||
-rw-r--r-- | perl-install/printer/detect.pm | 10 | ||||
-rw-r--r-- | perl-install/printer/gimp.pm | 14 | ||||
-rw-r--r-- | perl-install/printer/main.pm | 289 | ||||
-rw-r--r-- | perl-install/printer/office.pm | 16 | ||||
-rw-r--r-- | perl-install/printer/printerdrake.pm | 270 | ||||
-rw-r--r-- | perl-install/printer/services.pm | 2 |
8 files changed, 297 insertions, 308 deletions
diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm index 60efc7a04..127c342bb 100644 --- a/perl-install/printer/cups.pm +++ b/perl-install/printer/cups.pm @@ -8,7 +8,7 @@ use common; #------------------------------------------------------------------------------ -sub lpstat_v { +sub lpstat_v() { map { if (my ($queuename, $uri) = m/^\s*device\s+for\s+([^:\s]+):\s*(\S+)\s*$/) { +{ queuename => $queuename, uri => $uri, if_($uri =~ m!^ipp://([^/:]+)[:/]!, ipp => $1) }; diff --git a/perl-install/printer/default.pm b/perl-install/printer/default.pm index 5c15645d2..af997fd48 100644 --- a/perl-install/printer/default.pm +++ b/perl-install/printer/default.pm @@ -31,7 +31,7 @@ sub get_printer { return undef; } -sub printer_type($) { "LOCAL" } +sub printer_type() { "LOCAL" } sub get_spooler () { if (-f "$::prefix$FOOMATIC_DEFAULT_SPOOLER") { diff --git a/perl-install/printer/detect.pm b/perl-install/printer/detect.pm index 61c39522d..0839a6ad6 100644 --- a/perl-install/printer/detect.pm +++ b/perl-install/printer/detect.pm @@ -95,7 +95,7 @@ sub whatUsbport() { }; close $PORT; # Remove non-printable characters - $idstr =~ tr/[\x00-\x1f]/\./; + $idstr =~ tr/[\x00-\x1f]/./; # If we do not find any item in the ID string, we try to read # it again my $itemfound = 0; @@ -136,7 +136,7 @@ sub whatUsbport() { } # Nothing found? Try again if not in the third attempt, # in the third attempt always accept. - next if !$itemfound && ($j < 3); + next if !$itemfound && $j < 3; # Was there a manufacturer and a model in the string? if ($manufacturer eq "" || $model eq "") { $manufacturer = ""; @@ -203,7 +203,7 @@ sub whatNetPrinter { undef $modelinfo; - } elsif ($line =~ m/^\s*(\d+)\/\S+\s+open\s+/i) { + } elsif ($line =~ m!^\s*(\d+)/\S+\s+open\s+!i) { next if $ip eq ""; $port = $1; @@ -260,7 +260,7 @@ sub getNetworkInterfaces { if ($readline =~ /^(\S+)\s/) { my $dev = $1; if ($dev ne "lo") { - push (@interfaces, $dev); + push @interfaces, $dev; } } } @@ -291,7 +291,7 @@ sub getIPsOfLocalMachine { if ($readline =~ /^(\S+)\s/) { my $dev = $1; # ... for a real network (not lo = localhost) - $dev_is_realnet = ($dev ne 'lo'); + $dev_is_realnet = $dev ne 'lo'; # delete previous address $current_ip = ""; } diff --git a/perl-install/printer/gimp.pm b/perl-install/printer/gimp.pm index 61a3db1e2..dd36a514b 100644 --- a/perl-install/printer/gimp.pm +++ b/perl-install/printer/gimp.pm @@ -59,8 +59,8 @@ sub configure { $configfilecontent =~ s/\n/\nCurrent-Printer: $printer->{DEFAULT}\n/s; } else { - $configfilecontent =~ /^\s*Current\-Printer\s*:\s*(\S+)\s*$/m; - if (!isprinterconfigured($1, $configfilecontent)) { + if ($configfilecontent =~ /^\s*Current\-Printer\s*:\s*(\S+)\s*$/m && + !isprinterconfigured($1, $configfilecontent)) { $configfilecontent =~ s/(Current\-Printer\s*:\s*)\S+/$1$printer->{DEFAULT}/; } @@ -82,7 +82,7 @@ sub addcupsremoteto { if ($printer->{SPOOLER} eq "cups" && (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { foreach my $listentry (@printerlist) { - next if !($listentry =~ /^([^\|]+)\|([^\|]+)$/); + next if $listentry !~ /^([^\|]+)\|([^\|]+)$/; my $q = $1; next if $q ne $queue; my $server = $2; @@ -174,13 +174,11 @@ sub makeprinterentry { if ($ppd =~ /CUPS\s*\+\s*GIMP\s*\-\s*Print/im) { # Native CUPS driver $gimpprintqueue = 1; - $ppd =~ /\s*\*ModelName:\s*\"(\S+)\"\s*$/im; - $gimpprintdriver = $1; + $gimpprintdriver = $1 if $ppd =~ /\s*\*ModelName:\s*\"(\S+)\"\s*$/im; } elsif ($ppd =~ /Foomatic\s*\+\s*gimp\s*\-\s*print/im) { # GhostScript + Foomatic driver $gimpprintqueue = 1; - $ppd =~ - /\-sModel=((escp2|pcl|bjc|lexmark)\-[^\s\"\']*)/im; + $ppd =~ /\-sModel=((escp2|pcl|bjc|lexmark)\-[^\s\"']*)/im and $gimpprintdriver = $1; } if ($gimpprintqueue) { @@ -211,7 +209,7 @@ sub makeprinterentry { return $configfile; } -sub findconfigfiles { +sub findconfigfiles() { my @configfilenames = (if_(-d "$::prefix/usr/lib/gimp/1.2", ".gimp-1.2/printrc"), if_(-d "$::prefix/usr/lib/gimp/1.3", ".gimp-1.3/printrc")); return () unless @configfilenames; diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 51f9ad375..24fd91bc5 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -63,10 +63,10 @@ sub spooler { sub printer_type($) { my ($printer) = @_; for ($printer->{SPOOLER}) { - /cups/ && return @printer_type_inv{qw(LOCAL LPD SOCKET SMB), if_($::expert, qw(URI))}; - /lpd/ && return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($::expert, qw(POSTPIPE URI))}; - /lprng/ && return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($::expert, qw(POSTPIPE URI))}; - /pdq/ && return @printer_type_inv{qw(LOCAL LPD SOCKET), if_($::expert, qw(URI))}; + /cups/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB), if_($::expert, qw(URI))}; + /lpd/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($::expert, qw(POSTPIPE URI))}; + /lprng/ and return @printer_type_inv{qw(LOCAL LPD SOCKET SMB NCP), if_($::expert, qw(POSTPIPE URI))}; + /pdq/ and return @printer_type_inv{qw(LOCAL LPD SOCKET), if_($::expert, qw(URI))}; } } @@ -271,9 +271,10 @@ sub read_configured_queues($) { if ($printer->{SPOOLER} eq "cups") { $printer->{OLD_QUEUE} = $QUEUES[$i]{queuedata}{queue}; my $descr = get_descr_from_ppd($printer); - $descr =~ m/^([^\|]*)\|([^\|]*)(\|.*|)$/; - $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} ||= $1; - $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} ||= $2; + if ($descr =~ m/^([^\|]*)\|([^\|]*)(\|.*|)$/) { + $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{make} ||= $1; + $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{queuedata}{model} ||= $2; + } # Read out which PPD file was originally used to set up this # queue local *F; @@ -302,7 +303,7 @@ sub read_configured_queues($) { # Fill in "options" field if (my $args = $printer->{configured}{$QUEUES[$i]{queuedata}{queue}}{args}) { my @options; - foreach my $arg (@{$args}) { + foreach my $arg (@$args) { push(@options, "-o"); my $optstr = $arg->{name} . "=" . $arg->{default}; push(@options, $optstr); @@ -332,17 +333,17 @@ sub make_menuentry { my $connection; if ($connect =~ m!^(file|parallel):/dev/lp(\d+)$!) { my $number = $2; - $connection = N(" on parallel port \#%s", $number); + $connection = N(" on parallel port #%s", $number); } elsif ($connect =~ m!^(file|usb):/dev/usb/lp(\d+)$!) { my $number = $2; - $connection = N(", USB printer \#%s", $number); + $connection = N(", USB printer #%s", $number); } elsif ($connect =~ m!^usb://!) { $connection = N(", USB printer"); } elsif ($connect =~ m!^ptal:/(.+)$!) { my $ptaldevice = $1; if ($ptaldevice =~ /^mlc:par:(\d+)$/) { my $number = $1; - $connection = N(", multi-function device on parallel port \#%s", + $connection = N(", multi-function device on parallel port #%s", $number); } elsif ($ptaldevice =~ /^mlc:usb:/) { $connection = N(", multi-function device on USB"); @@ -520,7 +521,7 @@ sub read_printer_db(;$) { $entry->{driver} = "raw"; $entry->{make} = ""; $entry->{model} = N("Unknown model"); - map { $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} } keys %$entry; + $thedb{$entry->{ENTRY}}{$_} = $entry->{$_} foreach keys %$entry; #- Load CUPS driver database if CUPS is used as spooler if ($spooler && $spooler eq "cups") { @@ -716,24 +717,24 @@ sub read_location { my ($cupsd_conf_ptr, $path) = @_; - my @result = (); - if (grep(m!^\s*<Location\s+$path\s*>!, @{$cupsd_conf_ptr})) { + my @result; + if (grep { m!^\s*<Location\s+$path\s*>! } @$cupsd_conf_ptr) { my $location_start = -1; my $location_end = -1; # Go through all the lines, bail out when start and end line found for (my $i = 0; - ($i <= $#{$cupsd_conf_ptr}) and ($location_end == -1); + $i <= $#{$cupsd_conf_ptr} and $location_end == -1; $i++) { if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) { # Start line of block $location_start = $i; - } elsif (($cupsd_conf_ptr->[$i] =~ - m!^\s*<\s*/Location\s*>!) and - ($location_start != -1)) { + } elsif ($cupsd_conf_ptr->[$i] =~ + m!^\s*<\s*/Location\s*>! && + $location_start != -1) { # End line of block $location_end = $i; last; - } elsif (($location_start >= 0) and ($location_end < 0)) { + } elsif ($location_start >= 0 && $location_end < 0) { # Inside the location block push(@result, $cupsd_conf_ptr->[$i]); } @@ -759,20 +760,20 @@ sub rip_location { my ($cupsd_conf_ptr, $path) = @_; - my @location = (); + my @location; my $location_start = -1; my $location_end = -1; - if (grep(m!^\s*<Location\s+$path\s*>!, @{$cupsd_conf_ptr})) { + if (grep { m!^\s*<Location\s+$path\s*>! } @$cupsd_conf_ptr) { # Go through all the lines, bail out when start and end line found for (my $i = 0; - ($i <= $#{$cupsd_conf_ptr}) and ($location_end == -1); + $i <= $#{$cupsd_conf_ptr} and $location_end == -1; $i++) { if ($cupsd_conf_ptr->[$i] =~ m!^\s*<\s*Location\s+$path\s*>!) { # Start line of block $location_start = $i; - } elsif (($cupsd_conf_ptr->[$i] =~ - m!^\s*<\s*/Location\s*>!) and - ($location_start != -1)) { + } elsif ($cupsd_conf_ptr->[$i] =~ + m!^\s*<\s*/Location\s*>! && + $location_start != -1) { # End line of block $location_end = $i; last; @@ -780,7 +781,7 @@ sub rip_location { } # Rip out the block and store it seperately @location = - splice(@{$cupsd_conf_ptr},$location_start, + splice(@$cupsd_conf_ptr, $location_start, $location_end - $location_start + 1); } else { # If there is no location block, create one @@ -799,7 +800,7 @@ sub insert_location { my ($cupsd_conf_ptr, $location_start, @location) = @_; - splice(@{$cupsd_conf_ptr}, $location_start,0,@location); + splice(@$cupsd_conf_ptr, $location_start,0,@location); } sub add_to_location { @@ -887,7 +888,7 @@ sub broadcastaddress { $address =~ s/\*$/255.255/; } elsif ($address =~ /^\d+\.\d+\.\d+\.\*$/) { $address =~ s/\*$/255/; - } elsif ($address =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/) { + } elsif ($address =~ m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)$!) { my $numadr = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4; my $mask = ((1 << $5) - 1) << (32 - $5); my $broadcast = $numadr | (~$mask); @@ -897,7 +898,7 @@ sub broadcastaddress { (($broadcast & (255 << 8)) >> 8) . '.' . ($broadcast & 255); } elsif ($address =~ - /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { + m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)\.(\d+)\.(\d+)\.(\d+)$!) { my $numadr = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4; my $mask = ($5 << 24) + ($6 << 16) + ($7 << 8) + $8; my $broadcast = $numadr | (~$mask); @@ -931,9 +932,9 @@ sub localprintersshared { my ($printer) = @_; - return (($printer->{cupsconfig}{keys}{Browsing} !~ /off/i) && - ($printer->{cupsconfig}{keys}{BrowseInterval} != 0) && - ($#{$printer->{cupsconfig}{keys}{BrowseAddress}} >= 0)); + return ($printer->{cupsconfig}{keys}{Browsing} !~ /off/i && + $printer->{cupsconfig}{keys}{BrowseInterval} != 0 && + $#{$printer->{cupsconfig}{keys}{BrowseAddress}} >= 0); } sub remotebroadcastsaccepted { @@ -953,18 +954,18 @@ sub remotebroadcastsaccepted { } my $havedenyall = - (join('', @{$printer->{cupsconfig}{keys}{BrowseDeny}}) =~ - /All/im); + join('', @{$printer->{cupsconfig}{keys}{BrowseDeny}}) =~ + /All/im; my $havedenylocal = - (join('', @{$printer->{cupsconfig}{keys}{BrowseDeny}}) =~ - /\@LOCAL/im); + join('', @{$printer->{cupsconfig}{keys}{BrowseDeny}}) =~ + /\@LOCAL/im; my $orderallowdeny = - ($printer->{cupsconfig}{keys}{BrowseOrder} =~ - /allow\s*,\s*deny/i); + $printer->{cupsconfig}{keys}{BrowseOrder} =~ + /allow\s*,\s*deny/i; my $haveallowremote = 0; - for my $allowline (@{$printer->{cupsconfig}{keys}{BrowseAllow}}) { + foreach my $allowline (@{$printer->{cupsconfig}{keys}{BrowseAllow}}) { next if - ($allowline =~ /^\s*(localhost|0*127\.0+\.0+\.0*1|none)\s*$/i); + $allowline =~ /^\s*(localhost|0*127\.0+\.0+\.0*1|none)\s*$/i; $haveallowremote = 1; } @@ -1018,7 +1019,7 @@ sub clientnetworks { my $haveallowedhostwithoutbrowseaddress = 0; my $haveallowedhostwithoutbrowseallow = 0; # Go through all "Allow From" lines - for my $line (@{$printer->{cupsconfig}{root}{AllowFrom}}) { + foreach my $line (@{$printer->{cupsconfig}{root}{AllowFrom}}) { if ($line =~ /^\s*(localhost|0*127\.0+\.0+\.0*1)\s*$/i) { # Line pointing to localhost $haveallowfromlocalhost = 1; @@ -1039,12 +1040,12 @@ sub clientnetworks { } my $havebrowseaddresswithoutallowedhost = 0; # Go through all "BrowseAdress" lines - for my $line (@{$printer->{cupsconfig}{keys}{BrowseAddress}}) { + foreach my $line (@{$printer->{cupsconfig}{keys}{BrowseAddress}}) { if ($line =~ /^\s*(localhost|0*127\.0+\.0+\.0*1)\s*$/i) { # Skip lines pointing to localhost } elsif ($line =~ /^\s*(none)\s*$/i) { # Skip "Allow From None" lines - } elsif (!member($line, map {broadcastaddress($_)} @sharehosts)) { + } elsif (!member($line, map { broadcastaddress($_) } @sharehosts)) { # Line pointing to remote server push(@sharehosts, networkaddress($line)); if ($printer->{cupsconfig}{localprintersshared}) { @@ -1054,7 +1055,7 @@ sub clientnetworks { } my $havebrowseallowwithoutallowedhost = 0; # Go through all "BrowseAllow" lines - for my $line (@{$printer->{cupsconfig}{keys}{BrowseAllow}}) { + foreach my $line (@{$printer->{cupsconfig}{keys}{BrowseAllow}}) { if ($line =~ /^\s*(localhost|0*127\.0+\.0+\.0*1)\s*$/i) { # Skip lines pointing to localhost } elsif ($line =~ /^\s*(none)\s*$/i) { @@ -1086,12 +1087,12 @@ sub makesharehostlist { my @sharehostlist; my %sharehosthash; - for my $host (@{$printer->{cupsconfig}{clientnetworks}}) { + foreach my $host (@{$printer->{cupsconfig}{clientnetworks}}) { if ($host =~ /\@LOCAL/i) { $sharehosthash{$host} = N("Local network(s)"); } elsif ($host =~ /\@IF\((.*)\)/i) { $sharehosthash{$host} = N("Interface \"%s\"", $1); - } elsif ($host =~ /(\/|^\*|\*$|^\.)/) { + } elsif ($host =~ m!(/|^\*|\*$|^\.)!) { $sharehosthash{$host} = N("Network %s", $host); } else { $sharehosthash{$host} = N("Host %s", $host); @@ -1114,7 +1115,7 @@ sub makebrowsepolllist { my @browsepolllist; my %browsepollhash; - for my $host (@{$printer->{cupsconfig}{BrowsePoll}}) { + foreach my $host (@{$printer->{cupsconfig}{BrowsePoll}}) { my ($ip, $port); if ($host =~ /^([^:]+):([^:]+)$/) { $ip = $1; @@ -1139,11 +1140,11 @@ sub is_network_ip { my ($address) = @_; - ($address =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) || - ($address =~ /^(\d+\.){1,3}\*$/) || - ($address =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)$/) || - ($address =~ - /^(\d+)\.(\d+)\.(\d+)\.(\d+)\/(\d+)\.(\d+)\.(\d+)\.(\d+)$/); + $address =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ || + $address =~ /^(\d+\.){1,3}\*$/ || + $address =~ m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)$! || + $address =~ + m!^(\d+)\.(\d+)\.(\d+)\.(\d+)/(\d+)\.(\d+)\.(\d+)\.(\d+)$!; } @@ -1268,8 +1269,8 @@ sub write_cups_config { 'BrowseOrder Deny,Allow'); } } else { - if (($printer->{cupsconfig}{localprintersshared}) || - ($#{$printer->{cupsconfig}{BrowsePoll}} >= 0)) { + if ($printer->{cupsconfig}{localprintersshared} || + $#{$printer->{cupsconfig}{BrowsePoll}} >= 0) { # Deny all broadcasts, but leave all "BrowseAllow" lines # untouched handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, @@ -1296,10 +1297,10 @@ sub write_cups_config { "Allow From 127.0.0.1\n" . (@localips ? "Allow From " . - join("\nAllow From ", @localips). + join("\nAllow From ", @localips) . "\n" : "") . ($printer->{cupsconfig}{localprintersshared} && - ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) ? + $#{$printer->{cupsconfig}{clientnetworks}} >= 0 ? "Allow From " . join("\nAllow From ", grep { @@ -1315,8 +1316,8 @@ sub write_cups_config { if ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) { handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, 'BrowseAddress ' . - join ("\nBrowseAddress ", - map {broadcastaddress($_)} + join("\nBrowseAddress ", + map { broadcastaddress($_) } @{$printer->{cupsconfig}{clientnetworks}})); } else { handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf}, @@ -1326,7 +1327,7 @@ sub write_cups_config { if ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) { handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, 'BrowseAllow ' . - join ("\nBrowseAllow ", + join("\nBrowseAllow ", @{$printer->{cupsconfig}{clientnetworks}})); } else { handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf}, @@ -1338,7 +1339,7 @@ sub write_cups_config { if ($#{$printer->{cupsconfig}{BrowsePoll}} >= 0) { handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, 'BrowsePoll ' . - join ("\nBrowsePoll ", + join("\nBrowsePoll ", @{$printer->{cupsconfig}{BrowsePoll}})); # "Browsing" must be on for "BrowsePoll" to work handle_configs::set_directive($printer->{cupsconfig}{cupsd_conf}, @@ -1381,7 +1382,7 @@ sub read_printers_conf { chomp; /^\s*#/ and next; if (/^\s*<(?:DefaultPrinter|Printer)\s+([^>]*)>/) { $current = { mode => 'cups', QUEUE => $1, } } - elsif (/\s*<\/Printer>/) { $current->{QUEUE} && $current->{DeviceURI} or next; #- minimal check of synthax. + elsif (m!\s*</Printer>!) { $current->{QUEUE} && $current->{DeviceURI} or next; #- minimal check of synthax. add2hash($printer->{configured}{$current->{QUEUE}} ||= {}, $current); $current = undef } elsif (/\s*(\S*)\s+(.*)/) { $current->{$1} = $2 } } @@ -1439,7 +1440,7 @@ sub ppd_entry_str { } elsif ($descr =~ /Foomatic/i) { $descr =~ s/Foomatic/GhostScript/i; } elsif ($descr =~ /CUPS\+GIMP-print/i) { - $descr =~ s/CUPS\+GIMP-print/CUPS \+ GIMP-Print/i; + $descr =~ s/CUPS\+GIMP-print/CUPS + GIMP-Print/i; } elsif ($descr =~ /Series CUPS/i) { $descr =~ s/Series CUPS/Series, CUPS/i; } elsif ($descr !~ /(PostScript|GhostScript|CUPS|Foomatic)/i) { @@ -1448,19 +1449,19 @@ sub ppd_entry_str { # Split model and driver $descr =~ s/\s*Series//i; $descr =~ s/\((.*?(PostScript|PS.*).*?)\)/$1/i; - if (($descr =~ - /^\s*(Generic\s*PostScript\s*Printer)\s*,?\s*(.*)$/i) || - ($descr =~ - /^\s*(PostScript\s*Printer)\s*,?\s*(.*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s*(Foomatic.*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s*(GhostScript.*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s*(CUPS.*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s+(PS.*)$/i) || - ($descr =~ - /^([^,]+[^,\s])\s*,?\s*(\(v?\.?\s*\d\d\d\d\.\d\d\d\).*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s*(v\d+\.\d+.*)$/i) || - ($descr =~ /^([^,]+[^,\s])\s*,?\s*(PostScript.*)$/i) || - ($descr =~ /^([^,]+)\s*,?\s*(.+)$/)) { + if ($descr =~ + /^\s*(Generic\s*PostScript\s*Printer)\s*,?\s*(.*)$/i || + $descr =~ + /^\s*(PostScript\s*Printer)\s*,?\s*(.*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s*(Foomatic.*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s*(GhostScript.*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s*(CUPS.*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s+(PS.*)$/i || + $descr =~ + /^([^,]+[^,\s])\s*,?\s*(\(v?\.?\s*\d\d\d\d\.\d\d\d\).*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s*(v\d+\.\d+.*)$/i || + $descr =~ /^([^,]+[^,\s])\s*,?\s*(PostScript.*)$/i || + $descr =~ /^([^,]+)\s*,?\s*(.+)$/) { $model = $1; $driver = $2; $model =~ s/[\-\s,]+$//; @@ -1468,7 +1469,7 @@ sub ppd_entry_str { $driver =~ s/(PostScript)(.*)(PostScript)/$1$2/i; $driver =~ s/^\s*(\(?v?\.?\s*\d\d\d\d\.\d\d\d\)?|v\d+\.\d+)([,\s]*)(.*?)\s*$/$3$2$1/i; - $driver =~ s/,\s*\(/ \(/g; + $driver =~ s/,\s*\(/ (/g; $driver =~ s/[\-\s,]+$//; $driver =~ s/^[\-\s,]+//; $driver =~ s/\s+/ /g; @@ -1486,7 +1487,7 @@ sub ppd_entry_str { # name (do not do this with manufacturer names which contain # odd characters) $model =~ s/^$mf[\s\-]+//i - if ($mf and ($mf !~ /[\\\/\(\)\[\]\|\.\$\@\%\*\?]/)); + if $mf && $mf !~ m![\\/\(\)\[\]\|\.\$\@\%\*\?]!; # Clean some manufacturer's names $mf = clean_manufacturer_name($mf); # Rename Canon "BJC XXXX" models into "BJC-XXXX" so that the @@ -1507,7 +1508,7 @@ sub ppd_entry_str { # Try again to remove manufacturer's name from the beginning of the # model name, this with the cleaned manufacturer name $model =~ s/^$mf[\s\-]+//i - if ($mf and ($mf !~ /[\\\/\(\)\[\]\|\.\$\@\%\*\?]/)); + if $mf && $mf !~ m![\\/\(\)\[\]\|\.\$\@\%\*\?]!; # Put out the resulting description string uc($mf) . '|' . $model . '|' . $driver . ($lang && " (" . lc(substr($lang, 0, 2)) . ")"); @@ -1552,9 +1553,9 @@ sub ppd_devid_data { @content = cat_($ppd) or return ("", ""); } my ($devidmake, $devidmodel); - ($_ =~ /^\*Manufacturer:\s*\"(.*)\"\s*$/ and $devidmake = $1) + /^\*Manufacturer:\s*\"(.*)\"\s*$/ and $devidmake = $1 foreach @content; - ($_ =~ /^\*Product:\s*\"\(?(.*?)\)?\"\s*$/ and $devidmodel = $1) + /^\*Product:\s*\"\(?(.*?)\)?\"\s*$/ and $devidmodel = $1 foreach @content; return ($devidmake, $devidmodel); } @@ -1579,28 +1580,27 @@ sub poll_ppd_base { if ($ppd eq "raw") { next } $ppd && $mf && $descr and do { my $key = ppd_entry_str($mf, $descr, $lang); - $key =~ /^[^\|]+\|([^\|]+)\|(.*)$/; - my ($model, $driver) = ($1, $2); + my ($model, $driver) = ($1, $2) if $key =~ /^[^\|]+\|([^\|]+)\|(.*)$/; # Clean some manufacturer's names $mf = clean_manufacturer_name($mf); # Remove language tag $driver =~ s/\s*\([a-z]{2}(|_[A-Z]{2})\)\s*$//; # Recommended Foomatic PPD? Extract "(recommended)" my $isrecommended = - ($driver =~ s/\s+\(recommended\)\s*$//i); + $driver =~ s/\s+\(recommended\)\s*$//i; # Remove trailing white space $driver =~ s/\s+$//; # For Foomatic: Driver with "GhostScript + " my $fullfoomaticdriver = $driver; # Foomatic PPD? Extract driver name my $isfoomatic = - ($driver =~ s/^\s*(GhostScript|Foomatic)\s*\+\s*//i); + $driver =~ s/^\s*(GhostScript|Foomatic)\s*\+\s*//i; # Foomatic PostScript driver? - $isfoomatic ||= ($descr =~ /Foomatic/i); + $isfoomatic ||= $descr =~ /Foomatic/i; # Native CUPS? - my $isnativecups = ($driver =~ /CUPS/i); + my $isnativecups = $driver =~ /CUPS/i; # Native PostScript - my $isnativeps = (!$isfoomatic and !$isnativecups); + my $isnativeps = !$isfoomatic and !$isnativecups; # Key without language tag (key as it was produced for the # entries from the Foomatic XML database) my $keynolang = $key; @@ -1629,24 +1629,21 @@ sub poll_ppd_base { # and the new entry is a "recommended" driver other # then "Foomatic + Postscript" if (defined($thedb{$key})) { - next unless (lc($thedb{$key}{driver}) ne - lc($driver)); - next unless (($isnativeps && - ($thedb{$key}{driver} =~ - /^PostScript$/i)) || - (($thedb{$key}{driver} ne "PPD") && - $isrecommended) || - (($thedb{$key}{driver} eq "PPD") && - ($driver ne "PostScript") && - $isrecommended)); + next if lc($thedb{$key}{driver}) eq + lc($driver); + next unless $isnativeps && + $thedb{$key}{driver} =~ /^PostScript$/i || + $thedb{$key}{driver} ne "PPD" && $isrecommended || + $thedb{$key}{driver} eq "PPD" && $isrecommended && $driver ne "PostScript"; + # Remove the old entry delete $thedb{$key}; } - } elsif (((defined - $thedb{"$mf|$model|$fullfoomaticdriver"}) || - (defined - $thedb{"$mf|$model|$fullfoomaticdriver (recommended)"})) && - ($isfoomatic)) { + } elsif ((defined + $thedb{"$mf|$model|$fullfoomaticdriver"} || + defined + $thedb{"$mf|$model|$fullfoomaticdriver (recommended)"}) && + $isfoomatic) { # Expert mode: There is already an entry for the # same printer/driver combo produced by the # Foomatic XML database, so do not make a second @@ -1654,11 +1651,11 @@ sub poll_ppd_base { next; } elsif (defined $thedb{"$mf|$model|PostScript (recommended)"} && - ($isnativeps)) { + $isnativeps) { # Expert mode: "Foomatic + Postscript" driver is # recommended and this is a PostScript PPD? Make # this PPD the recommended one - for (keys + foreach (keys %{$thedb{"$mf|$model|PostScript (recommended)"}}) { $thedb{"$mf|$model|PostScript"}{$_} = $thedb{"$mf|$model|PostScript (recommended)"}{$_}; @@ -1668,7 +1665,7 @@ sub poll_ppd_base { if (!$isrecommended) { $key .= " (recommended)"; } - } elsif (($driver =~ /PostScript/i) && + } elsif ($driver =~ /PostScript/i && $isrecommended && $isfoomatic && (my @foundkeys = grep { /^$mf\|$model\|/ && !/CUPS/i && @@ -1678,17 +1675,17 @@ sub poll_ppd_base { # recommended and there was a PostScript PPD? Make # the PostScript PPD the recommended one my $firstfound = $foundkeys[0]; - if (!(grep {/\(recommended\)/} @foundkeys)) { + if (!(grep { /\(recommended\)/ } @foundkeys)) { # Do it only if none of the native PostScript # PPDs for this printer is already "recommended" - for (keys %{$thedb{$firstfound}}) { + foreach (keys %{$thedb{$firstfound}}) { $thedb{"$firstfound (recommended)"}{$_} = $thedb{$firstfound}{$_}; } delete $thedb{$firstfound}; } $key =~ s/\s*\(recommended\)//; - } elsif (($driver !~ /PostScript/i) && + } elsif ($driver !~ /PostScript/i && $isrecommended && $isfoomatic && (my @foundkeys = grep { /^$mf\|$model\|.*\(recommended\)/ && @@ -1702,7 +1699,7 @@ sub poll_ppd_base { # Remove the "recommended" tag my $destkey = $sourcekey; $destkey =~ s/\s+\(recommended\)\s*$//i; - for (keys %{$thedb{$sourcekey}}) { + foreach (keys %{$thedb{$sourcekey}}) { $thedb{$destkey}{$_} = $thedb{$sourcekey}{$_}; } delete $thedb{$sourcekey}; @@ -1787,10 +1784,10 @@ sub configure_queue($) { # Check whether a USB printer is configured and activate USB printing if so my $useUSB = 0; foreach (values %{$printer->{configured}}) { - $useUSB ||= (($_->{queuedata}{connect} =~ /usb/i) || - ($_->{DeviceURI} =~ /usb/i)); + $useUSB ||= $_->{queuedata}{connect} =~ /usb/i || + $_->{DeviceURI} =~ /usb/i; } - $useUSB ||= ($printer->{currentqueue}{connect} =~ /usb/i); + $useUSB ||= $printer->{currentqueue}{connect} =~ /usb/i; if ($useUSB) { my $f = "$::prefix/etc/sysconfig/usb"; my %usb = getVarsFromSh($f); @@ -1853,11 +1850,11 @@ sub restart_queue($) { # Restart the daemon(s) for ($printer->{SPOOLER}) { - /cups/ && do { + /cups/ and do { #- restart cups. printer::services::restart("cups"); last }; - /lpr|lprng/ && do { + /lpr|lprng/ and do { #- restart lpd. foreach ("/var/spool/lpd/$queue/lock", "/var/spool/lpd/lpd.lock") { my $pidlpd = (cat_("$::prefix$_"))[0]; @@ -1922,8 +1919,7 @@ sub help_output { open F, ($::testing ? $::prefix : "chroot $::prefix/ ") . sprintf($spoolers{$spooler}{help}, $queue); my $helptext = join("", <F>); close F; - $helptext = "Option list not available!\n" - if (!$helptext || $helptext eq ""); + $helptext ||= "Option list not available!\n"; return $helptext; } @@ -2031,7 +2027,7 @@ sub autodetectionentry_for_uri { my $make = $1; my $model = $2; my $serial = $4; - if ($make and $model) { + if ($make && $model) { $make =~ s/\%20/ /g; $model =~ s/\%20/ /g; $serial =~ s/\%20/ /g; @@ -2041,17 +2037,17 @@ sub autodetectionentry_for_uri { my $smodel = handle_configs::searchstr($model); foreach my $p (@autodetected) { next if $p->{port} !~ /usb/i; - next if ((!$p->{val}{MANUFACTURER} or - ($p->{val}{MANUFACTURER} ne $make)) and - (!$p->{val}{DESCRIPTION} or - ($p->{val}{DESCRIPTION} !~ /^\s*$smake\s+/))); - next if ((!$p->{val}{MODEL} or - ($p->{val}{MODEL} ne $model)) and - (!$p->{val}{DESCRIPTION} or - ($p->{val}{DESCRIPTION} !~ /\s+$smodel\s*$/))); - next if ($serial and - (!$p->{val}{SERIALNUMBER} or - ($p->{val}{SERIALNUMBER} ne $serial))); + next if ((!$p->{val}{MANUFACTURER} || + $p->{val}{MANUFACTURER} ne $make) && + (!$p->{val}{DESCRIPTION} || + $p->{val}{DESCRIPTION} !~ /^\s*$smake\s+/)); + next if ((!$p->{val}{MODEL} || + $p->{val}{MODEL} ne $model) && + (!$p->{val}{DESCRIPTION} || + $p->{val}{DESCRIPTION} !~ /\s+$smodel\s*$/)); + next if ($serial && + (!$p->{val}{SERIALNUMBER} || + $p->{val}{SERIALNUMBER} ne $serial)); return $p; } } @@ -2062,18 +2058,17 @@ sub autodetectionentry_for_uri { if ($ptaldevice =~ /^par:(\d+)$/) { my $device = "/dev/lp$1"; foreach my $p (@autodetected) { - next if (!$p->{port} or - ($p->{port} ne $device)); + next if !$p->{port} || + $p->{port} ne $device; return $p; } } else { - $ptaldevice =~ /^usb:(.*)$/; - my $model = $1; + my $model = $1 if $ptaldevice =~ /^usb:(.*)$/; $model =~ s/_/ /g; my $device = ""; foreach my $p (@autodetected) { - next if (!$p->{val}{MODEL} or - ($p->{val}{MODEL} ne $model)); + next if !$p->{val}{MODEL} || + $p->{val}{MODEL} ne $model; return $p; } } @@ -2083,8 +2078,8 @@ sub autodetectionentry_for_uri { my $device = $uri; $device =~ s/^(file|parallel|usb|serial)://; foreach my $p (@autodetected) { - next if (!$p->{port} or - ($p->{port} ne $device)); + next if !$p->{port} || + $p->{port} ne $device; return $p; } } @@ -2113,14 +2108,14 @@ sub configure_hpoj { while (<PTALINIT>) { if (m!sub main!) { last; - } elsif (m!^[^\#]!) { + } elsif (m!^[^#]!) { # Make the subroutines also working during installation if ($::isInstall) { s!\$::prefix!\$hpoj_prefix!g; - s!prefix=\"/usr\"!prefix=\"$::prefix/usr\"!g; - s!etcPtal=\"/etc/ptal\"!etcPtal=\"$::prefix/etc/ptal\"!g; - s!varLock=\"/var/lock\"!varLock=\"$::prefix/var/lock\"!g; - s!varRunPrefix=\"/var/run\"!varRunPrefix=\"$::prefix/var/run\"!g; + s!prefix="/usr"!prefix="$::prefix/usr"!g; + s!etcPtal="/etc/ptal"!etcPtal="$::prefix/etc/ptal"!g; + s!varLock="/var/lock"!varLock="$::prefix/var/lock"!g; + s!varRunPrefix="/var/run"!varRunPrefix="$::prefix/var/run"!g; } push @ptalinitfunctions, $_; } @@ -2165,12 +2160,11 @@ sub configure_hpoj { if ($device =~ /usb/) { $bus = "usb"; } elsif ($device =~ /par/ || - $device =~ /\/dev\/lp/ || + $device =~ m!/dev/lp! || $device =~ /printers/) { $bus = "par"; $address_arg = printer::detect::parport_addr($device); - $address_arg =~ /^\s*-base\s+(\S+)/; - eval "$base_address = $1"; + eval "$base_address = $1" if $address_arg =~ /^\s*-base\s+(\S+)/; } elsif ($device =~ /socket/) { $bus = "hpjd"; $hostname = $model; @@ -2442,13 +2436,12 @@ EOF my $mtoolsfmconf; if (-f "$::prefix/etc/mtoolsfm.conf") { $mtoolsfmconf = cat_("$::prefix/etc/mtoolsfm.conf") or die "can't read MToolsFM config in $::prefix/etc/mtoolsfm.conf: $!"; - $mtoolsfmconf =~ m/^\s*DRIVES\s*=\s*\"([A-Za-z ]*)\"/m; - my $alloweddrives = lc($1); + my $alloweddrives = lc($1) if $mtoolsfmconf =~ m/^\s*DRIVES\s*=\s*\"([A-Za-z ]*)\"/m; foreach my $letter ("p", "q", "r", "s") { $alloweddrives .= $letter if $alloweddrives !~ /$letter/; } - $mtoolsfmconf =~ s/^\s*DRIVES\s*=\s*\"[A-Za-z ]*\"/DRIVES=\"$alloweddrives\"/m; - $mtoolsfmconf =~ s/^\s*LEFTDRIVE\s*=\s*\"[^\"]*\"/LEFTDRIVE=\"p\"/m; + $mtoolsfmconf =~ s/^\s*DRIVES\s*=\s*"[A-Za-z ]*"/DRIVES="$alloweddrives"/m; + $mtoolsfmconf =~ s/^\s*LEFTDRIVE\s*=\s*"[^"]*"/LEFTDRIVE="p"/m; } else { $mtoolsfmconf = <<'EOF'; # MToolsFM config file. comments start with a hash sign. diff --git a/perl-install/printer/office.pm b/perl-install/printer/office.pm index fb905107d..eccde17b5 100644 --- a/perl-install/printer/office.pm +++ b/perl-install/printer/office.pm @@ -44,8 +44,7 @@ sub configureoffice { # Do we have Star Office installed? my $configfilename = find_config_file($suite); return 1 unless $configfilename; - $configfilename =~ m!$suites->{$suite}{file_name}!; - my $configprefix = $1; + my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; # Load Star Office printer config file my $configfilecontent = cat_("$::prefix$configfilename"); # Update remote CUPS queues @@ -53,7 +52,7 @@ sub configureoffice { (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { my @printerlist = printer::cups::get_remote_queues(); foreach my $listentry (@printerlist) { - next unless ($listentry =~ /^([^\|]+)\|([^\|]+)$/); + next unless $listentry =~ /^([^\|]+)\|([^\|]+)$/; my $queue = $1; my $server = $2; if (-x "$::prefix/usr/bin/wget") { @@ -119,8 +118,7 @@ sub add_cups_remote_to_office { # Do we have Star Office installed? my $configfilename = find_config_file($suite); return 1 unless $configfilename; - $configfilename =~ m!$suites->{$suite}{file_name}!; - my $configprefix = $1; + my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; # Load Star Office printer config file my $configfilecontent = cat_("$::prefix$configfilename"); # Update remote CUPS queues @@ -128,7 +126,7 @@ sub add_cups_remote_to_office { (-x "$::prefix/usr/bin/curl" || -x "$::prefix/usr/bin/wget")) { my @printerlist = printer::cups::get_remote_queues(); foreach my $listentry (@printerlist) { - next unless ($listentry =~ /^([^\|]+)\|([^\|]+)$/); + next unless $listentry =~ /^([^\|]+)\|([^\|]+)$/; my $q = $1; next if $q ne $queue; my $server = $2; @@ -169,8 +167,7 @@ sub remove_printer_from_office { # Do we have Star Office installed? my $configfilename = find_config_file($suite); return 1 unless $configfilename; - $configfilename =~ m!$suites->{$suite}{file_name}!; - my $configprefix = $1; + my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; # Load Star Office printer config file my $configfilecontent = cat_("$::prefix$configfilename"); # Remove the printer entry @@ -186,8 +183,7 @@ sub remove_local_printers_from_office { # Do we have Star Office installed? my $configfilename = find_config_file($suite); return 1 unless $configfilename; - $configfilename =~ m!$suites->{$suite}{file_name}!; - my $configprefix = $1; + my $configprefix = $1 if $configfilename =~ m!$suites->{$suite}{file_name}!; # Load Star Office printer config file my $configfilecontent = cat_("$::prefix$configfilename"); # Remove the printer entries diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 25aff729f..bb1f4887b 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -229,15 +229,15 @@ If some of these measures lead to problems for you, turn this option off, but th messages => N("Choose the network or host on which the local printers should be made available:"), callbacks => { complete => sub { - if (($hostchoice eq - N("IP address of host/network:")) && + if ($hostchoice eq + N("IP address of host/network:") && $ip =~ /^\s*$/) { $in->ask_warn('', N("Host/network IP address missing.")); return (1,1); } - if (($hostchoice eq - N("IP address of host/network:")) && + if ($hostchoice eq + N("IP address of host/network:") && !printer::main::is_network_ip($ip)) { $in->ask_warn('', @@ -257,7 +257,7 @@ N("Examples for correct IPs:\n") . $address = $ip; } else { ($address) = - grep {$hostchoice =~ /$_/} + grep { $hostchoice =~ /$_/ } @interfaces; $address = "\@IF($address)"; } @@ -287,7 +287,7 @@ N("Examples for correct IPs:\n") . disabled => sub { $hostchoice ne N("IP address of host/network:"); - }}, + } }, ], )) { # OK was clicked, insert new item into the list @@ -296,9 +296,9 @@ N("Examples for correct IPs:\n") . $address); } else { @{$printer->{cupsconfig}{clientnetworks}} = - map {($_ eq + map { ($_ eq $sharehosts->{invhash}{$choice} ? - $address : $_)} + $address : $_) } @{$printer->{cupsconfig}{clientnetworks}}; } # Refresh list of hosts @@ -312,7 +312,7 @@ N("Examples for correct IPs:\n") . } } elsif ($buttonclicked eq "remove") { @{$printer->{cupsconfig}{clientnetworks}} = - grep {$_ ne $sharehosts->{invhash}{$choice}} + grep { $_ ne $sharehosts->{invhash}{$choice} } @{$printer->{cupsconfig}{clientnetworks}}; # Refresh list of hosts $sharehosts = @@ -462,9 +462,9 @@ N("Examples for correct IPs:\n") . $address); } else { @{$printer->{cupsconfig}{BrowsePoll}} = - map {($_ eq + map { ($_ eq $browsepoll->{invhash}{$choice} ? - $address : $_)} + $address : $_) } @{$printer->{cupsconfig}{BrowsePoll}}; } # Refresh list of hosts @@ -476,7 +476,7 @@ N("Examples for correct IPs:\n") . } } elsif ($buttonclicked eq "remove") { @{$printer->{cupsconfig}{BrowsePoll}} = - grep {$_ ne $browsepoll->{invhash}{$choice}} + grep { $_ ne $browsepoll->{invhash}{$choice} } @{$printer->{cupsconfig}{BrowsePoll}}; # Refresh list of hosts $browsepoll = @@ -686,7 +686,7 @@ sub configure_new_printers { $queue =~ s/(\d)$/$1_/; my $i = 1; while ($printer->{configured}{"$queue$i"}) { - $i ++; + $i++; } $queue .= $i; } @@ -716,7 +716,7 @@ sub configure_new_printers { $printer->{DBENTRY} = N("Raw printer (No driver)"); # Info about what was detected my $info = N("(") . if_($p->{val}{DESCRIPTION}, - $p->{val}{DESCRIPTION} . N(" on ")). + $p->{val}{DESCRIPTION} . N(" on ")) . $p->{port} . N(")"); # Remove wait message undef $_w; @@ -740,7 +740,7 @@ Printerdrake could not determine which model your printer %s is. Please choose t $queue =~ s/(\d)$/$1_/; my $i = 1; while ($printer->{configured}{"$queue$i"}) { - $i ++; + $i++; } $queue .= $i; } @@ -764,7 +764,7 @@ Printerdrake could not determine which model your printer %s is. Please choose t } } # Delete some variables - foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE)){ + foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE)) { $printer->{$_} = ""; } $printer->{currentqueue} = {}; @@ -935,9 +935,9 @@ sub setup_local_autoscan { if ($p->{val}{DESCRIPTION}) { my $menustr = $p->{val}{DESCRIPTION}; if ($p->{port} =~ m!^/dev/lp(\d+)$!) { - $menustr .= N(" on parallel port \#%s", $1); + $menustr .= N(" on parallel port #%s", $1); } elsif ($p->{port} =~ m!^/dev/usb/lp(\d+)$!) { - $menustr .= N(", USB printer \#%s", $1); + $menustr .= N(", USB printer #%s", $1); } elsif ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) { $menustr .= N(", network printer \"%s\", port %s", $1, $2); } elsif ($p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!) { @@ -949,9 +949,9 @@ sub setup_local_autoscan { } else { my $menustr; if ($p->{port} =~ m!^/dev/lp(\d+)$!) { - $menustr = N("Printer on parallel port \#%s", $1); + $menustr = N("Printer on parallel port #%s", $1); } elsif ($p->{port} =~ m!^/dev/usb/lp(\d+)$!) { - $menustr = N("USB printer \#%s", $1); + $menustr = N("USB printer #%s", $1); } elsif ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) { $menustr .= N("Network printer \"%s\", port %s", $1, $2); } elsif ($p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!) { @@ -972,9 +972,9 @@ sub setup_local_autoscan { } my $menustr; if ($q =~ m!^/dev/lp(\d+)$!) { - $menustr = N("Printer on parallel port \#%s", $1); + $menustr = N("Printer on parallel port #%s", $1); } elsif ($q =~ m!^/dev/usb/lp(\d+)$!) { - $menustr = N("USB printer \#%s", $1); + $menustr = N("USB printer #%s", $1); } $menustr .= " ($q)" if $::expert; $menuentries->{$menustr} = $q; @@ -989,10 +989,10 @@ sub setup_local_autoscan { $printer->{MORETHANONE} = $#autodetected > 0; my $m; for ($m = 0; $m <= 2; $m++) { - my $menustr = N("Printer on parallel port \#%s", $m); + my $menustr = N("Printer on parallel port #%s", $m); $menustr .= " (/dev/lp$m)" if $::expert; $menuentries->{$menustr} = "/dev/lp$m"; - $menustr = N("USB printer \#%s", $m); + $menustr = N("USB printer #%s", $m); $menustr .= " (/dev/usb/lp$m)" if $::expert; $menuentries->{$menustr} = "/dev/usb/lp$m"; } @@ -1009,7 +1009,7 @@ sub setup_local_autoscan { if ($secondinlist && !$firstinlist) { return 1 }; } return $first cmp $second; - } keys(%{$menuentries}); + } keys(%$menuentries); my $menuchoice = ""; my $oldmenuchoice = ""; my $device; @@ -1147,9 +1147,10 @@ sub setup_lpd { if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m/^lpd:/) { $uri = $printer->{currentqueue}{connect}; - $uri =~ m!^\s*lpd://([^/]+)/([^/]+)/?\s*$!; - $remotehost = $1; - $remotequeue = $2; + if ($uri =~ m!^\s*lpd://([^/]+)/([^/]+)/?\s*$!) { + $remotehost = $1; + $remotequeue = $2; + } } else { $remotehost = ""; $remotequeue = "lp"; @@ -1218,8 +1219,7 @@ sub setup_smb { if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m/^smb:/) { $uri = $printer->{currentqueue}{connect}; - $uri =~ m!^\s*smb://(.*)$!; - my $parameters = $1; + my $parameters = $1 if $uri =~ m!^\s*smb://(.*)$!; # Get the user's login and password from the URI if ($parameters =~ m!([^@]*)@([^@]+)!) { my $login = $1; @@ -1268,9 +1268,10 @@ sub setup_smb { @autodetected = printer::detect::net_smb_detect(); foreach my $p (@autodetected) { my $menustr; - $p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!; - my $server = $1; - my $share = $2; + if ($p->{port} =~ m!^smb://([^/:]+)/([^/:]+)$!) { + my $server = $1; + my $share = $2; + } if ($p->{val}{DESCRIPTION}) { $menustr = $p->{val}{DESCRIPTION}; $menustr .= N(", printer \"%s\" on server \"%s\"", @@ -1287,7 +1288,7 @@ sub setup_smb { } @menuentrieslist = sort { $menuentries->{$a} cmp $menuentries->{$b}; - } keys(%{$menuentries}); + } keys(%$menuentries); if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m/^smb:/ && $menuchoice eq "") { @@ -1308,10 +1309,11 @@ sub setup_smb { $autodetect = 0; } elsif ($menuchoice eq "") { $menuchoice = $menuentrieslist[0]; - $menuentries->{$menuentrieslist[0]} =~ - m!^smb://([^/:]+)/([^/:]+)$!; - $smbserver = $1; - $smbshare = $2; + if ($menuentries->{$menuentrieslist[0]} =~ + m!^smb://([^/:]+)/([^/:]+)$!) { + $smbserver = $1; + $smbshare = $2; + } } $oldmenuchoice = $menuchoice; } @@ -1373,9 +1375,10 @@ Do you really want to continue setting up this printer as you are doing now?"), changed => sub { return 0 if !$autodetect; if ($oldmenuchoice ne $menuchoice) { - $menuentries->{$menuchoice} =~ m!^smb://([^/:]+)/([^/:]+)$!; - $smbserver = $1; - $smbshare = $2; + if ($menuentries->{$menuchoice} =~ m!^smb://([^/:]+)/([^/:]+)$!) { + $smbserver = $1; + $smbshare = $2; + } $oldmenuchoice = $menuchoice; } return 0; @@ -1504,9 +1507,10 @@ sub setup_socket { @autodetected = printer::detect::net_detect(); foreach my $p (@autodetected) { my $menustr; - $p->{port} =~ m!^socket://([^:]+):(\d+)$!; - my $host = $1; - my $port = $2; + if ($p->{port} =~ m!^socket://([^:]+):(\d+)$!) { + my $host = $1; + my $port = $2; + } if ($p->{val}{DESCRIPTION}) { $menustr = $p->{val}{DESCRIPTION}; $menustr .= N(", host \"%s\", port %s", @@ -1522,7 +1526,7 @@ sub setup_socket { } @menuentrieslist = sort { $menuentries->{$a} cmp $menuentries->{$b}; - } keys(%{$menuentries}); + } keys(%$menuentries); if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m!^(socket:|ptal:/hpjd:)! && $menuchoice eq "") { @@ -1543,9 +1547,10 @@ sub setup_socket { $autodetect = 0; } elsif ($menuchoice eq "") { $menuchoice = $menuentrieslist[0]; - $menuentries->{$menuentrieslist[0]} =~ m!^socket://([^:]+):(\d+)$!; - $remotehost = $1; - $remoteport = $2; + if ($menuentries->{$menuentrieslist[0]} =~ m!^socket://([^:]+):(\d+)$!) { + $remotehost = $1; + $remoteport = $2; + } } $oldmenuchoice = $menuchoice; } @@ -1571,10 +1576,11 @@ sub setup_socket { changed => sub { return 0 if !$autodetect; if ($oldmenuchoice ne $menuchoice) { - $menuentries->{$menuchoice} =~ m!^socket://([^:]+):(\d+)$!; - $remotehost = $1; - $remoteport = $2; - $oldmenuchoice = $menuchoice; + if ($menuentries->{$menuchoice} =~ m!^socket://([^:]+):(\d+)$!) { + $remotehost = $1; + $remoteport = $2; + } + $oldmenuchoice = $menuchoice; } return 0; } @@ -1724,8 +1730,7 @@ sub setup_postpipe { if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m/^postpipe:/) { $uri = $printer->{currentqueue}{connect}; - $uri =~ m!^\s*postpipe:\"(.*)\"$!; - $commandline = $1; + $commandline = $1 if $uri =~ m!^\s*postpipe:\"(.*)\"$!; } else { $commandline = ""; } @@ -1759,7 +1764,7 @@ sub setup_common { my $ptaldevice = ""; my $isHPOJ = 0; my $_w; - if ($device =~ /^\/dev\// || $device =~ /^socket:\/\//) { + if ($device =~ m!^/dev/! || $device =~ m!^socket://!) { # Ask user whether he has a multi-function device when he didn't # do auto-detection or when auto-detection failed my $searchunknown = N("Unknown model"); @@ -1782,7 +1787,7 @@ sub setup_common { /usr/bin/xojpanel))) { $_w = $in->wait_message(N("Printerdrake"), N("Installing HPOJ package...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; $in->do_pkgs->install('hpoj', 'xojpanel'); } # Configure and start HPOJ @@ -1790,7 +1795,7 @@ sub setup_common { $_w = $in->wait_message (N("Printerdrake"), N("Checking device and configuring HPOJ...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; $ptaldevice = printer::main::configure_hpoj ($device, @autodetected); @@ -1811,7 +1816,7 @@ sub setup_common { $_w = $in->wait_message (N("Printerdrake"), N("Installing SANE packages...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; $in->do_pkgs->install('sane-backends', 'sane-frontends', 'xsane', 'libsane-hpoj0', @@ -1837,7 +1842,7 @@ sub setup_common { $_w = $in->wait_message (N("Printerdrake"), N("Installing mtools packages...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; $in->do_pkgs->install('mtools', 'mtoolsfm'); } # Configure mtools/MToolsFM for photo card access @@ -1872,7 +1877,7 @@ sub setup_common { $_w = $in->wait_message (N("Printerdrake"), N("Checking device and configuring HPOJ...")) - if (!$printer->{noninteractive} && !defined($_w)); + if !$printer->{noninteractive} && !defined($_w); } else { # make the DeviceURI from $device. $printer->{currentqueue}{connect} = $device; @@ -1909,16 +1914,16 @@ sub setup_common { my $_w = $in->wait_message (N("Printerdrake"), N("Making printer port available for CUPS...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; printer::main::assure_device_is_available_for_cups($ptaldevice || $device); } #- Read the printer driver database if necessary - if ((keys %printer::main::thedb) == 0) { + if (keys %printer::main::thedb == 0) { my $_w = $in->wait_message (N("Printerdrake"), N("Reading printer database...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; printer::main::read_printer_db($printer->{SPOOLER}); } @@ -1938,14 +1943,14 @@ sub setup_common { $descr = "$descrmake|$automodel"; } else { $descr = $autodescr; - $descr =~ s/ /\|/; + $descr =~ s/ /|/; } # Remove manufacturer's name from the beginning of the # description (do not do this with manufacturer names which # contain odd characters) - $descr =~ s/^$descrmake\|\s*$descrmake\s*/$descrmake\|/i - if ($descrmake and - ($descrmake !~ /[\\\/\(\)\[\]\|\.\$\@\%\*\?]/)); + $descr =~ s/^$descrmake\|\s*$descrmake\s*/$descrmake|/i + if $descrmake && + $descrmake !~ m![\\/\(\)\[\]\|\.\$\@\%\*\?]!; # Clean up the description from noise which makes the best match # difficult $descr =~ s/\s+[Ss]eries//i; @@ -2019,7 +2024,7 @@ sub setup_common { $matched = 0; } } - if ($matched && ($des || ($mfg && $mdl))) { + if ($matched && ($des || $mfg && $mdl)) { # Full match to known auto-detection data $printer->{DBENTRY} = $entry; $matchlength = 1000; @@ -2033,8 +2038,7 @@ sub setup_common { # Foomatic database or of thr PPD file my $dbmakemodel; if ($::expert) { - $entry =~ m/^(.*)\|[^\|]*$/; - $dbmakemodel = $1; + $dbmakemodel = $1 if $entry =~ m/^(.*)\|[^\|]*$/; } else { $dbmakemodel = $entry; } @@ -2068,7 +2072,7 @@ sub setup_common { if (!member($descr, @badsearchterms)) { my $searchterm = $descr; my $lsearchterm = length($searchterm); - $searchterm =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + $searchterm =~ s!([\\/\(\)\[\]\|\.\$\@\%\*\?])!\\$1!g; if ($lsearchterm > $matchlength && $dbmakemodel =~ m!$searchterm!i) { $matchlength = $lsearchterm; @@ -2078,7 +2082,7 @@ sub setup_common { if (!member($dbmakemodel, @badsearchterms)) { my $searchterm = $dbmakemodel; my $lsearchterm = length($searchterm); - $searchterm =~ s/([\\\/\(\)\[\]\|\.\$\@\%\*\?])/\\$1/g; + $searchterm =~ s!([\\/\(\)\[\]\|\.\$\@\%\*\?])!\\$1!g; if ($lsearchterm > $matchlength && $descr =~ m!$searchterm!i) { $matchlength = $lsearchterm; @@ -2093,8 +2097,7 @@ sub setup_common { bestMatchSentence($descr, keys %printer::main::thedb); # If the manufacturer was not guessed correctly, discard the # guess. - $printer->{DBENTRY} =~ /^([^\|]+)\|/; - my $guessedmake = lc($1); + my $guessedmake = lc($1) if $printer->{DBENTRY} =~ /^([^\|]+)\|/; if ($guessedmake !~ /Generic/i && $descr !~ /$guessedmake/i && ($guessedmake ne "hp" || @@ -2155,15 +2158,15 @@ N("Every printer needs a name (for example \"printer\"). The Description and Loc sub get_db_entry { my ($printer, $in) = @_; #- Read the printer driver database if necessary - if ((keys %printer::main::thedb) == 0) { + if (keys %printer::main::thedb == 0) { my $_w = $in->wait_message(N("Printerdrake"), N("Reading printer database...")) - if (!$printer->{noninteractive}); + if $printer->{noninteractive}; printer::main::read_printer_db($printer->{SPOOLER}); } my $_w = $in->wait_message(N("Printerdrake"), N("Preparing printer database...")) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; my $queue = $printer->{OLD_QUEUE}; if ($printer->{configured}{$queue}) { # The queue was already configured @@ -2211,9 +2214,10 @@ sub get_db_entry { } elsif ($printer->{configured}{$queue}{queuedata}{ppd}) { my $makemodel = printer::main::get_descr_from_ppd($printer); - $makemodel =~ m!^([^\|]+)\|([^\|]+)(|\|.*)$!; - $make = $1; - $model = $2; + if ($makemodel =~ m!^([^\|]+)\|([^\|]+)(|\|.*)$!) { + $make = $1; + $model = $2; + } } foreach my $key (keys %printer::main::thedb) { if ($::expert && @@ -2243,8 +2247,7 @@ sub get_db_entry { bestMatchSentence($matchstr, keys %printer::main::thedb); # If the manufacturer was not guessed correctly, discard the # guess. - $printer->{DBENTRY} =~ /^([^\|]+)\|/; - my $guessedmake = lc($1); + my $guessedmake = lc($1) if $printer->{DBENTRY} =~ /^([^\|]+)\|/; if ($matchstr !~ /$guessedmake/i && ($guessedmake ne "hp" || $matchstr !~ /Hewlett[\s-]+Packard/i)) @@ -2299,7 +2302,7 @@ sub choose_model { my ($printer, $in) = @_; # $in->set_help('chooseModel') if $::isInstall; #- Read the printer driver database if necessary - if ((keys %printer::main::thedb) == 0) { + if (keys %printer::main::thedb == 0) { my $_w = $in->wait_message(N("Printerdrake"), N("Reading printer database...")); printer::main::read_printer_db($printer->{SPOOLER}); @@ -2444,14 +2447,15 @@ sub get_printer_info { return 0; } # Set device permissions - $printer->{currentqueue}{connect} =~ - /^\s*(file|parallel|usb):(\S*)\s*$/; - if ($printer->{SPOOLER} eq 'cups') { - set_permissions($2, '660', 'lp', 'sys'); - } elsif ($printer->{SPOOLER} eq 'pdq') { - set_permissions($2, '666'); - } else { - set_permissions($2, '660', 'lp', 'lp'); + if ($printer->{currentqueue}{connect} =~ + /^\s*(file|parallel|usb):(\S*)\s*$/) { + if ($printer->{SPOOLER} eq 'cups') { + set_permissions($2, '660', 'lp', 'sys'); + } elsif ($printer->{SPOOLER} eq 'pdq') { + set_permissions($2, '666'); + } else { + set_permissions($2, '660', 'lp', 'lp'); + } } # This is needed to have the device not blocked by the # spooler backend. @@ -2597,10 +2601,10 @@ You should make sure that the page size and the ink type/printing mode (if avail my $optshortdefault = $printer->{ARGS}[$i]{default}; # Should the option only show when the "Advanced" button was # clicked? - my $advanced = ((defined($printer->{ARGS}[$i]{group}) and + my $advanced = ((defined($printer->{ARGS}[$i]{group}) && ($printer->{ARGS}[$i]{group} !~ - /^(|General|.*install.*)$/i)) or - (!($printer->{ARGS}[$i]{group}) and + /^(|General|.*install.*)$/i)) || + (!($printer->{ARGS}[$i]{group}) && !member($printer->{ARGS}[$i]{name}, @simple_options)) ? 1 : 0); # Group header @@ -2685,15 +2689,13 @@ You should make sure that the page size and the ink type/printing mode (if avail } } elsif ($printer->{currentqueue}{ppd}) { if ($printer->{DBENTRY}) { - $printer->{DBENTRY} =~ /^[^\|]*\|[^\|]*\|(.*)$/; - $driver = $1; + $driver = $1 if $printer->{DBENTRY} =~ /^[^\|]*\|[^\|]*\|(.*)$/; } else { $driver = printer::main::get_descr_from_ppd($printer); if ($driver =~ /^[^\|]*\|[^\|]*$/) { # No driver info $driver = "PPD"; } else { - $driver =~ /^[^\|]*\|[^\|]*\|(.*)$/; - $driver = $1; + $driver = $1 if $driver =~ /^[^\|]*\|[^\|]*\|(.*)$/; } } } @@ -2704,8 +2706,8 @@ You should make sure that the page size and the ink type/printing mode (if avail } # Do not show the options setup dialog when installing a new printer # in recommended mode without "Manual configuration" turned on. - if ((!$printer->{NEW} or $::expert or $printer->{MANUAL}) and - (!$printer->{noninteractive})) { + if ((!$printer->{NEW} || $::expert || $printer->{MANUAL}) && + !$printer->{noninteractive}) { return 0 if !$in->ask_from( $windowtitle, N("Printer default settings"), @@ -2852,11 +2854,11 @@ Note: the photo test page can take a rather long time to get printed and on lase $in->do_pkgs->install('ImageMagick'); } # set up list of pages to print - $options{standard} && push @testpages, $stdtestpage; - $options{altletter} && push @testpages, $altlttestpage; - $options{alta4} && push @testpages, $alta4testpage; - $options{photo} && push @testpages, $phototestpage; - $options{ascii} && push @testpages, $asciitestpage; + $options{standard} and push @testpages, $stdtestpage; + $options{altletter} and push @testpages, $altlttestpage; + $options{alta4} and push @testpages, $alta4testpage; + $options{photo} and push @testpages, $phototestpage; + $options{ascii} and push @testpages, $asciitestpage; # print the stuff @lpq_output = printer::main::print_pages($printer, @testpages); } @@ -2948,7 +2950,7 @@ N("This command you can also use in the \"Printing command\" field of the printi (!$raw ? N(" The \"%s\" command also allows to modify the option settings for a particular printing job. Simply add the desired settings to the command line, e. g. \"%s <file>\". ", "lpr", ($queue ne $default ? "lpr -P $queue -Z option=setting -Z switch" : "lpr -Z option=setting -Z switch")) . -N("To get a list of the options available for the current printer click on the \"Print option list\" button.") . $scanning . $photocard . $hp11000fw: $scanning . $photocard . $hp11000fw); +N("To get a list of the options available for the current printer click on the \"Print option list\" button.") . $scanning . $photocard . $hp11000fw : $scanning . $photocard . $hp11000fw); } elsif ($spooler eq "lpd") { $dialogtext = N("To print a file from the command line (terminal window) use the command \"%s <file>\". @@ -3469,7 +3471,7 @@ sub configure_queue { my $_w = $in->wait_message(N("Printerdrake"), N("Configuring printer \"%s\"...", $printer->{currentqueue}{queue})) - if (!$printer->{noninteractive}); + if !$printer->{noninteractive}; $printer->{complete} = 1; my $retval = printer::main::configure_queue($printer); $printer->{complete} = 0; @@ -3568,7 +3570,7 @@ sub main { # Get the default printer (Done before non-interactive queue setup, # so that former default is not lost) assure_default_printer_is_set($printer, $in); - my $nodefault = (!$printer->{DEFAULT}); + my $nodefault = !$printer->{DEFAULT}; # Non-interactive setup of newly detected printers (This is done # only when not in expert mode, so we always have a spooler defined @@ -3596,7 +3598,7 @@ sub main { # Main loop: During installation we only enter it when the user has # clicked on the "Configure" button in the "Summary" step. We do not # call it during the preparation of the "Summary" screen. - if (!$::isInstall || ($install_step == 1)) { + if (!$::isInstall || $install_step == 1) { # Ask for a spooler when none is defined yet $printer->{SPOOLER} ||= @@ -3745,16 +3747,16 @@ sub main { my $spooler = $spoolers{$printer->{SPOOLER}}{short_name}; if ($::expert) { - map { + foreach (keys(%{$printer->{configured}})) { $printer->{configured}{$_}{queuedata}{menuentry} =~ s/^/$spooler!/; - } keys(%{$printer->{configured}}); + } $cursorpos =~ s/^/$spooler!/; } else { - map { + foreach (keys(%{$printer->{configured}})) { $printer->{configured}{$_}{queuedata}{menuentry} =~ s/^$spooler!//; - } keys(%{$printer->{configured}}); + } $cursorpos =~ s/^$spooler!//; } next; @@ -3843,14 +3845,14 @@ sub main { goto step_0; }; step_3: - if ($::expert or $printer->{MANUAL} or + if ($::expert || $printer->{MANUAL} || $printer->{MORETHANONE}) { choose_printer_name($printer, $in) or goto step_2; } get_db_entry($printer, $in); step_3_9: - if (!$::expert and !$printer->{MANUAL}) { + if (!$::expert && !$printer->{MANUAL}) { is_model_correct($printer, $in) or do { goto step_3 if $printer->{MORETHANONE}; goto step_2; @@ -3859,7 +3861,7 @@ sub main { step_4: # Remember DB entry for "Previous" button in wizard my $dbentry = $printer->{DBENTRY}; - if ($::expert or $printer->{MANUAL} or + if ($::expert || $printer->{MANUAL} || $printer->{MANUALMODEL}) { choose_model($printer, $in) or do { # Restore DB entry @@ -3900,15 +3902,15 @@ sub main { wizard_welcome($printer, $in, $upNetwork) or next; !$::expert or choose_printer_type($printer, $in) or next; setup_printer_connection($printer, $in, $upNetwork) or next; - if ($::expert or $printer->{MANUAL} or + if ($::expert || $printer->{MANUAL} || $printer->{MORETHANONE}) { choose_printer_name($printer, $in) or next; } get_db_entry($printer, $in); - if (!$::expert and !$printer->{MANUAL}) { + if (!$::expert && !$printer->{MANUAL}) { is_model_correct($printer, $in) or next; } - if ($::expert or $printer->{MANUAL} or + if ($::expert || $printer->{MANUAL} || $printer->{MANUALMODEL}) { choose_model($printer, $in) or next; } @@ -3939,21 +3941,21 @@ sub main { # Here we must regenerate the menu entry, because the # parameters can be changed. printer::main::make_menuentry($printer,$queue); - $printer->{configured}{$queue}{queuedata}{menuentry} =~ - /!([^!]+)$/; - $infoline = $1 . - ($queue eq $printer->{DEFAULT} ? N(" (Default)") : '') . - ($printer->{configured}{$queue}{queuedata}{desc} ? - ", Descr.: $printer->{configured}{$queue}{queuedata}{desc}" : '') . - ($printer->{configured}{$queue}{queuedata}{loc} ? - ", Loc.: $printer->{configured}{$queue}{queuedata}{loc}" : '') . - ($::expert ? - ", Driver: $printer->{configured}{$queue}{queuedata}{driver}" : ''); + if ($printer->{configured}{$queue}{queuedata}{menuentry} =~ + /!([^!]+)$/) { + $infoline = $1 . + ($queue eq $printer->{DEFAULT} ? N(" (Default)") : '') . + ($printer->{configured}{$queue}{queuedata}{desc} ? + ", Descr.: $printer->{configured}{$queue}{queuedata}{desc}" : '') . + ($printer->{configured}{$queue}{queuedata}{loc} ? + ", Loc.: $printer->{configured}{$queue}{queuedata}{loc}" : '') . + ($::expert ? + ", Driver: $printer->{configured}{$queue}{queuedata}{driver}" : ''); + } } else { # The parameters of a remote CUPS queue cannot be # changed, so we can simply take the menu entry. - $cursorpos =~ /!([^!]+)$/; - $infoline = $1; + $infoline = $1 if $cursorpos =~ /!([^!]+)$/; } if ($in->ask_from_( { title => N("Modify printer configuration"), @@ -4106,8 +4108,8 @@ What do you want to modify on this printer?", } else { my $s1 = N(" (Default)"); my $s2 = $s1; - $s2 =~ s/\(/\\\(/; - $s2 =~ s/\)/\\\)/; + $s2 =~ s/\(/\\(/; + $s2 =~ s/\)/\\)/; $cursorpos .= $s1 if $printer->{QUEUE} eq $printer->{DEFAULT} && $cursorpos !~ /$s2/; } } @@ -4122,7 +4124,7 @@ What do you want to modify on this printer?", undef $_w; } # Delete some variables - foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE)){ + foreach (qw(OLD_QUEUE QUEUE TYPE str_type DBENTRY ARGS OLD_CHOICE)) { $printer->{$_} = ""; } $printer->{currentqueue} = {}; diff --git a/perl-install/printer/services.pm b/perl-install/printer/services.pm index 1b68da96a..adb2587fe 100644 --- a/perl-install/printer/services.pm +++ b/perl-install/printer/services.pm @@ -39,7 +39,7 @@ sub start_not_running_service ($) { } } -sub wait_for_cups { +sub wait_for_cups() { # CUPS needs some time to come up. Wait up to 30 seconds, checking # whether CUPS is ready. my $cupsready = 0; |