From dba8fab056173ce124e1c151fb46277af8d35282 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 8 Jul 2005 08:38:51 +0000 Subject: reduce the overall perl_checker warnings --- perl-install/lvm.pm | 2 +- perl-install/network/ipsec.pm | 80 +++++++++------------- perl-install/printer/cups.pm | 8 +-- perl-install/printer/main.pm | 28 ++++---- perl-install/printer/printerdrake.pm | 124 +++++++++++++++++------------------ perl-install/scanner.pm | 16 ++--- 6 files changed, 120 insertions(+), 138 deletions(-) diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm index 802096e43..05beddc19 100644 --- a/perl-install/lvm.pm +++ b/perl-install/lvm.pm @@ -70,7 +70,7 @@ sub get_pv_field { } sub pv_physical_extents { my ($pv) = @_; - split(' ', lvm::get_pv_field($pv, 'pv_pe_alloc_count,pv_pe_count')) + split(' ', lvm::get_pv_field($pv, 'pv_pe_alloc_count,pv_pe_count')); } sub pv_to_vg { my ($pv) = @_; diff --git a/perl-install/network/ipsec.pm b/perl-install/network/ipsec.pm index b40e6c79b..c0ca7689e 100644 --- a/perl-install/network/ipsec.pm +++ b/perl-install/network/ipsec.pm @@ -21,7 +21,7 @@ sub recreate_ipsec_conf { print "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; } else { print "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; + } } } } else { @@ -40,8 +40,8 @@ sub recreate_ipsec_conf { $ipsec->{$key1}{protocol} . "/" . $ipsec->{$key1}{mode} . "/" . $ipsec->{$key1}{src_dest} . "/" . - $ipsec->{$key1}{level} . ";\n" - }; + $ipsec->{$key1}{level} . ";\n"; + } } } } @@ -57,7 +57,7 @@ sub recreate_racoon_conf { print "}\n$racoon->{$key1}\n" if ! $racoon->{$key1}{1}; } else { print "$racoon->{$key1}\n" if ! $racoon->{$key1}{1}; - }; + } $in_a_section = "n"; $in_a_proposal_section = "n"; foreach my $key2 (ikeys %{$racoon->{$key1}}) { @@ -106,7 +106,7 @@ sub recreate_ipsec_conf1_k24 { print "$key1-->$key2-->$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; } else { print "\t$key2-->$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; + } } } } @@ -122,7 +122,7 @@ sub start_daemons () { sys("/etc/rc.d/init.d/$_ start >/dev/null"), sys("/sbin/chkconfig --level 345 $_ on") foreach 'ipsec'; } else { - }; + } sys("/etc/rc.d/init.d/$_ start >/dev/null"), sys("/sbin/chkconfig --level 345 $_ on") foreach 'shorewall'; } @@ -132,9 +132,9 @@ sub stop_daemons () { if (-e "/etc/rc.d/init.d/ipsec") { foreach (qw(ipsec)) { system("/etc/rc.d/init.d/$_ status >/dev/null 2>/dev/null") == 0 and sys("/etc/rc.d/init.d/$_ stop"); - }; + } sys("/sbin/chkconfig --level 345 $_ off") && -e "/etc/rc.d/init.d/$_" foreach 'ipsec'; - }; + } system("/etc/rc.d/init.d/shorewall status >/dev/null 2>/dev/null") == 0 and sys("/etc/rc.d/init.d/shorewall stop >/dev/null"); } @@ -181,7 +181,7 @@ sub read_racoon_conf { $line =~ /(.*)#(.*)/ if $line !~ /^#/; #- define before and after comment # print "--line-->$line\n"; my $data_part = $1; - my $comment_part = "#".$2; + my $comment_part = "#" . $2; if ($data_part) { $data_part =~ s/,//g; # print "@@".$data_part."->".$comment_part."\n"; @@ -211,7 +211,7 @@ sub read_racoon_conf { $nb++; put_in_hash(\%conf, { $nb => $line }); $in_a_section = "n"; - }; + } } elsif ($line =~ /^sainfo|^remote|^listen|^timer|^padding/ && $in_a_section eq "n") { $i=1; $nb++; @@ -227,8 +227,8 @@ sub read_racoon_conf { } else { put_in_hash($conf{$nb} ||= {}, { $i => [@line1] }); $i++; - }; - }; + } + } \%conf; } @@ -237,22 +237,15 @@ sub display_racoon_conf { my ($racoon) = @_; my $display = ""; my $prefix_to_simple_line = ""; - my $pt; foreach my $key1 (ikeys %$racoon) { if (!$racoon->{$key1}{1}) { $display .= $prefix_to_simple_line . $racoon->{$key1} . "\n"; $prefix_to_simple_line = ""; } else { foreach my $key2 (ikeys %{$racoon->{$key1}}) { - if ($key2 > 1) { - $pt = $racoon->{$key1}{$key2-1}[0]; - } else { - $pt = $racoon->{$key1}{1}[0]; - }; my $t = $racoon->{$key1}{1}[0]; my $f = $racoon->{$key1}{$key2}[0]; my $list_length = scalar @{$racoon->{$key1}{$key2}}; - my $already_read = 0; my $line = ""; if ($racoon->{$key1}{$key2}[0] eq "sainfo" && !$racoon->{$key1}{$key2}[2]) { @@ -278,8 +271,6 @@ sub display_racoon_conf { } else { $line .= "$c "; } - - $already_read = 1; } } @@ -308,22 +299,15 @@ sub write_racoon_conf { my ($racoon_conf, $racoon) = @_; my $display = ""; my $prefix_to_simple_line = ""; - my $pt; foreach my $key1 (ikeys %$racoon) { if (!$racoon->{$key1}{1}) { $display .= $prefix_to_simple_line . $racoon->{$key1} . "\n"; $prefix_to_simple_line = ""; } else { foreach my $key2 (ikeys %{$racoon->{$key1}}) { - if ($key2 > 1) { - $pt = $racoon->{$key1}{$key2-1}[0]; - } else { - $pt = $racoon->{$key1}{1}[0]; - }; my $t = $racoon->{$key1}{1}[0]; my $f = $racoon->{$key1}{$key2}[0]; my $list_length = scalar @{$racoon->{$key1}{$key2}}; - my $already_read = 0; my $line = ""; if ($racoon->{$key1}{$key2}[0] eq "sainfo" && !$racoon->{$key1}{$key2}[2]) { @@ -349,9 +333,7 @@ sub write_racoon_conf { } else { $line .= "$c "; } - - $already_read = 1; - } + } } if ($f =~ /^timer|^listen|^padding|^remote|^sainfo/) { @@ -392,7 +374,7 @@ sub get_section_names_racoon_conf { if ($s !~ /^#|^proposal/) { $section_title .= $separator . $s; $separator = " "; - }; + } } push(@section_names, $section_title) if $section_title ne ""; } @@ -425,11 +407,11 @@ sub matched_section_key_number_racoon_conf { if ($s !~ /^#|^proposal/) { $section_title .= $separator . $s; $separator = " "; - }; - }; + } + } if ($section_title eq $section_name) { return $key1; - }; + } } } @@ -450,7 +432,7 @@ sub already_existing_section_racoon_conf { if ($s !~ /^#|^proposal/) { $section_title .= $separator . $s; $separator = " "; - }; + } } $section_title eq $section_name; @@ -524,7 +506,7 @@ sub read_ipsec_conf { $nb++; put_in_hash(\%conf, { $nb => $line }); $in_a_conn = "n"; - }; + } } elsif ($line =~ /^conn|^config|^version/ && $in_a_conn eq "n") { @line1 = split /\s+/,$line; $i=1; @@ -542,8 +524,8 @@ sub read_ipsec_conf { @line1 = split /=/,$line; put_in_hash($conf{$nb} ||= {}, { $i => [$line1[0], $line1[1]] }); $i++; - }; - }; + } + } } else { #- kernel 2.6 part ------------------------------- @@ -577,10 +559,10 @@ sub read_ipsec_conf { } else { $nb++; put_in_hash(\%conf, { $nb => $myline }); - }; - }; + } + } - }; + } \%conf; } @@ -599,7 +581,7 @@ sub write_ipsec_conf { print $ADD "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; } else { print $ADD "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n" if $ipsec->{$key1}{$key2}[0] && $ipsec->{$key1}{$key2}[1]; - }; + } } } } else { @@ -619,8 +601,8 @@ sub write_ipsec_conf { $ipsec->{$key1}{protocol} . "/" . $ipsec->{$key1}{mode} . "/" . $ipsec->{$key1}{src_dest} . "/" . - $ipsec->{$key1}{level} . ";\n" - }; + $ipsec->{$key1}{level} . ";\n"; + } } open(my $ADD, "> $ipsec_conf") or die "Can not open the $ipsec_conf file for writing"; print $ADD $display; @@ -642,7 +624,7 @@ sub display_ipsec_conf { $display .= "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]\n"; } else { $display .= "\t$ipsec->{$key1}{$key2}[0]=$ipsec->{$key1}{$key2}[1]\n"; - }; + } } } @@ -682,7 +664,7 @@ sub get_section_names_ipsec_conf { foreach my $key2 (ikeys %{$ipsec->{$key1}}) { if ($ipsec->{$key1}{$key2}[0] =~ m/(^conn|^config|^version)/) { push(@section_names, "$ipsec->{$key1}{$key2}[0] $ipsec->{$key1}{$key2}[1]"); - }; + } } } @@ -691,7 +673,7 @@ sub get_section_names_ipsec_conf { foreach my $key1 (ikeys %$ipsec) { if ($ipsec->{$key1}{command} =~ m/(^spdadd)/) { push(@section_names, "$ipsec->{$key1}{src_range} $ipsec->{$key1}{dst_range}"); - }; + } } } @@ -756,7 +738,7 @@ sub already_existing_section_ipsec_conf { return "already existing"; } } - }; + } return "no"; } diff --git a/perl-install/printer/cups.pm b/perl-install/printer/cups.pm index 64b0df045..0ddff19f0 100644 --- a/perl-install/printer/cups.pm +++ b/perl-install/printer/cups.pm @@ -27,8 +27,8 @@ sub lpstat_lpv() { my $currentitem = -1; for my $line (@lpstat) { - chomp ($line); - if (!($line =~ m!^\s*$!)) { + chomp($line); + if ($line !~ m!^\s*$!) { if ($line =~ m!^printer\s+(\S+)\s+(\S.*)$!) { # Beginning of new printer's entry my $name = $1; @@ -51,7 +51,7 @@ sub lpstat_lpv() { my $name = $1; my $uri = $2; if (defined($itemshash->{$name})) { - if ($uri !~ /:/) {$uri = "file:" . $uri}; + if ($uri !~ /:/) { $uri = "file:" . $uri } $currentitem = $itemshash->{$name}; if (($currentitem <= $#items) && ($items[$currentitem]{queuename} eq $name)) { @@ -136,7 +136,7 @@ sub get_remote_queues { sub queue_enabled { my ($queue) = @_; 0 != grep { - /\b$queue\b.*\benabled\b/i + /\b$queue\b.*\benabled\b/i; } run_program::rooted_get_stdout($::prefix, 'lpstat', '-p', $queue); } diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index 55b2ca727..7407fc691 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -80,9 +80,9 @@ sub printer_type($) { sub SIGHUP_daemon { my ($service) = @_; - if ($service eq "cupsd") { $service = "cups" }; + if ($service eq "cupsd") { $service = "cups" } # PDQ and remote CUPS have no daemons, exit. - if (($service eq "pdq") || ($service eq "rcups")) { return 1 }; + if (($service eq "pdq") || ($service eq "rcups")) { return 1 } # CUPS needs auto-correction for its configuration run_program::rooted($::prefix, "/usr/sbin/correctcupsconfig") if $service eq "cups"; # Name of the daemon @@ -741,7 +741,7 @@ sub set_jap_textmode { # When installing CUPS later it will not work. return 1 if (! -r "$::prefix/etc/cups/mime.convs"); substInFile { - s!^(\s*text/plain\s+\S+\s+\d+\s+)\S+(\s*$)!$1${textmode}texttops$2! + s!^(\s*text/plain\s+\S+\s+\d+\s+)\S+(\s*$)!$1${textmode}texttops$2!; } "$::prefix/etc/cups/mime.convs"; return 1; } @@ -1008,7 +1008,7 @@ sub networkaddress { my ($address) = @_; if ($address =~ /\.255$/) { - while ($address =~ s/\.255$//) {}; + while ($address =~ s/\.255$//) {} $address .= ".*"; } @@ -1295,7 +1295,7 @@ sub read_cups_config { my @localips = printer::detect::getIPsOfLocalMachine(); @{$printer->{cupsconfig}{root}{AllowFrom}} = grep { - !member($_, @localips) + !member($_, @localips); } @{$printer->{cupsconfig}{root}{AllowFrom}}; # Keyword "Deny from" @@ -1393,7 +1393,7 @@ sub write_cups_config { "Allow From " . join("\nAllow From ", grep { - !member($_, @localips) + !member($_, @localips); } @{$printer->{cupsconfig}{clientnetworks}}) . "\n" : "") . "\n"; @@ -1410,7 +1410,7 @@ sub write_cups_config { @{$printer->{cupsconfig}{clientnetworks}})); } else { handle_configs::comment_directive($printer->{cupsconfig}{cupsd_conf}, - 'BrowseAddress') + 'BrowseAddress'); } # Set "BrowseAllow" lines if ($#{$printer->{cupsconfig}{clientnetworks}} >= 0) { @@ -1469,7 +1469,7 @@ sub read_client_conf() { sub write_client_conf { my ($daemonless_cups, $remote_cups_server) = @_; # Create the directory for client.conf if needed - (-d "$::prefix/etc/cups/" ) || mkdir("$::prefix/etc/cups/") || return 1; + (-d "$::prefix/etc/cups/") || mkdir("$::prefix/etc/cups/") || return 1; my (@client_conf) = cat_("$::prefix/etc/cups/client.conf"); if ($daemonless_cups) { handle_configs::set_directive(\@client_conf, @@ -1836,7 +1836,7 @@ sub poll_ppd_base { $isrecommended && $isfoomatic && (my @foundkeys = grep { /^$mf\|$model\|/ && !/CUPS/i && - $thedb{$_}{driver} eq "PPD" + $thedb{$_}{driver} eq "PPD"; } keys %thedb)) { # Expert mode: "Foomatic + Postscript" driver is # recommended and there was a PostScript PPD? Make @@ -1856,7 +1856,7 @@ sub poll_ppd_base { $isrecommended && $isfoomatic && (@foundkeys = grep { /^$mf\|$model\|.*$sprecstr/ && - !/CUPS/i && $thedb{$_}{driver} eq "PPD" + !/CUPS/i && $thedb{$_}{driver} eq "PPD"; } keys %thedb)) { # Expert mode: Foomatic driver other than "Foomatic + # Postscript" is recommended and there was a PostScript @@ -1885,7 +1885,7 @@ sub poll_ppd_base { #my ($devidmake, $devidmodel) = ppd_devid_data($ppd); #$thedb{$key}{devidmake} = $devidmake; #$thedb{$key}{devidmodel} = $devidmodel; - } + }; } close $PPDS; scalar(keys %thedb) - $driversthere > 5 and last; @@ -1932,7 +1932,7 @@ sub configure_queue($) { "-N", $printer->{currentqueue}{desc}, "-L", $printer->{currentqueue}{loc}, @{$printer->{currentqueue}{options}} - ) or return 0;; + ) or return 0; if ($printer->{currentqueue}{ppd} && ($printer->{currentqueue}{ppd} ne '1')) { # Add a comment line containing the path of the used PPD file to the @@ -2580,7 +2580,7 @@ sub remove_hpoj_config { my $host = $1; if ($file =~ /$host/) { closedir PTALDIR; - unlink ($file) or return $file; + unlink($file) or return $file; printer::services::restart("hpoj"); return undef; } @@ -2590,7 +2590,7 @@ sub remove_hpoj_config { (grep { /$d->{val}{SERIALNUMBER}/ } chomp_(cat_($file))))) { closedir PTALDIR; - unlink ($file) or return $file; + unlink($file) or return $file; printer::services::restart("hpoj"); return undef; } diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 076ec9314..33bb7dbb4 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -33,7 +33,7 @@ sub config_cups { local $::isEmbedded = 0; # Check whether the network functionality is configured and # running - if (!check_network($printer, $in, $upNetwork, 0)) { return 0 }; + if (!check_network($printer, $in, $upNetwork, 0)) { return 0 } #$in->set_help('configureRemoteCUPSServer') if $::isInstall; #- hack to handle cups remote server printing, @@ -94,8 +94,8 @@ sub config_cups { }, disabled => sub { $daemonless_cups || - (!$printer->{cupsconfig}{localprintersshared} && - !$printer->{cupsconfig}{remotebroadcastsaccepted}); + !$printer->{cupsconfig}{localprintersshared} && + !$printer->{cupsconfig}{remotebroadcastsaccepted}; } }, { val => N("Additional CUPS servers: ") . ($#{$browsepoll->{list}} >= 0 ? @@ -523,7 +523,7 @@ N("Examples for correct IPs:\n") . type => 'list', sort => 0, list => [ N("Off"), - N("On, Name or IP of remote server:") ]}, + N("On, Name or IP of remote server:") ] }, { val => \$rserver, disabled => sub { $modechoice ne @@ -533,7 +533,7 @@ N("Examples for correct IPs:\n") . )) { # OK was clicked, update the data $daemonless_cups = - ($modechoice eq N("On, Name or IP of remote server:")); + $modechoice eq N("On, Name or IP of remote server:"); $remote_cups_server = $rserver; } } else { @@ -550,8 +550,8 @@ N("Examples for correct IPs:\n") . printer::main::set_jap_textmode($jap_textmode); # Switch state of daemon-less CUPS mode and write # client.conf - if (($daemonless_cups && $printer->{SPOOLER} ne "rcups") || - (!$daemonless_cups && $printer->{SPOOLER} eq "rcups")) { + if ($daemonless_cups && $printer->{SPOOLER} ne "rcups" || + !$daemonless_cups && $printer->{SPOOLER} eq "rcups") { my $oldspooler = $printer->{SPOOLER}; $printer->{SPOOLER} = ($daemonless_cups ? "rcups" : "cups"); @@ -643,8 +643,8 @@ Printers on remote CUPS servers do not need to be configured here; these printer } return 0; } - }}, - [ { val => \$timeout } ] ); + } }, + [ { val => \$timeout } ]); 0; } }, ], @@ -747,7 +747,7 @@ sub first_time_dialog { \@choices, $quit); return 0 if $choice ne $do_it; - if ($havelocalnetworks && !@autodetected ) { + if ($havelocalnetworks && !@autodetected) { return set_cups_daemon_mode($printer, $in); } else { $printer->{SPOOLER} = "cups"; @@ -932,11 +932,11 @@ sub generate_queuename { my $ml = 12; if (length($queue) > $ml) { my %parts; - $parts{'make'} = $make; - $parts{'model'} = $model; + $parts{make} = $make; + $parts{model} = $model; # Go through the two components, begin with model name, then # make and then driver - for my $part (qw/model make/) { + foreach my $part (qw(model make)) { $parts{$part} =~ s/[^a-zA-Z0-9_]/ /g; # Split the component into words, cutting always at the @@ -946,39 +946,39 @@ sub generate_queuename { split(/(?<=[a-zA-Z])(?![a-zA-Z])|(?<=[a-z])(?=[A-Z])/, $parts{$part}); # Go through all words - for (@words) { + foreach (@words) { # Do not abbreviate words of less than 3 letters - next if ($_ !~ /[a-zA-Z]{3,}$/); + next if !/[a-zA-Z]{3,}$/; while (1) { # Remove the last letter chop; # Build the shortened component ... $parts{$part} = join('', @words); # ... and the queue name - $queue = "$parts{'make'} $parts{'model'}"; + $queue = "$parts{make} $parts{model}"; $queue =~ s/\s+//g; # Stop if the queue name has 12 characters or # less, if there is only one letter left, or if # the manufacturer name is reduced to three # characters. last if ((length($queue) <= $ml) || - ($_ !~ /[a-zA-Z]{2,}$/) || + (!/[a-zA-Z]{2,}$/) || (($part eq 'make') && - (length($parts{'make'}) <= 3))); + (length($parts{make}) <= 3))); } $parts{$part} = join('', @words); - $queue = "$parts{'make'} $parts{'model'}"; + $queue = "$parts{make} $parts{model}"; $queue =~ s/\s+//g; last if (length($queue) <= $ml); } last if (length($queue) <= $ml); } while ((length($queue) > $ml) && - (length($parts{'model'}) > 3)) { + (length($parts{model}) > 3)) { # Queue name too long? Remove last words from model name. - $parts{'model'} =~ - s/[^a-zA-Z0-9]+[a-zA-Z0-9]*$// || last; - $queue = "$parts{'make'} $parts{'model'}"; + last if !($parts{model} =~ + s/[^a-zA-Z0-9]+[a-zA-Z0-9]*$//); + $queue = "$parts{make} $parts{model}"; $queue =~ s/\s+//g; } if (length($queue) > $ml) { @@ -1003,7 +1003,7 @@ sub generate_queuename { $queue .= $i; } last if (!$printer->{configured}{$queue}); - $i ++; + $i++; } } @@ -1173,7 +1173,7 @@ Congratulations, your printer is now installed and configured! You can print using the \"Print\" command of your application (usually in the \"File\" menu). -If you want to add, remove, or rename a printer, or if you want to change the default option settings (paper input tray, printout quality, ...), select \"Printer\" in the \"Hardware\" section of the %s Control Center.", $shortdistroname)) +If you want to add, remove, or rename a printer, or if you want to change the default option settings (paper input tray, printout quality, ...), select \"Printer\" in the \"Hardware\" section of the %s Control Center.", $shortdistroname)); } } @@ -1315,8 +1315,8 @@ sub setup_local_autoscan { for (my $i = 0; $i <= $#prefixes; $i++) { my $firstinlist = $first =~ m!^$prefixes[$i]!; my $secondinlist = $second =~ m!^$prefixes[$i]!; - if ($firstinlist && !$secondinlist) { return -1 }; - if ($secondinlist && !$firstinlist) { return 1 }; + if ($firstinlist && !$secondinlist) { return -1 } + if ($secondinlist && !$firstinlist) { return 1 } } return $first cmp $second; } keys(%$menuentries); @@ -1338,7 +1338,7 @@ sub setup_local_autoscan { } if ($in) { # $printer->{expert} or $in->set_help('configurePrinterDev') if $::isInstall; - if ($#menuentrieslist < 0) { # No menu entry + if (@menuentrieslist < 1) { # No menu entry # auto-detection has failed, we must do all manually $do_auto_detect = 0; $printer->{MANUAL} = 1; @@ -1455,7 +1455,7 @@ sub setup_lpd { local $::isEmbedded = 0; # Check whether the network functionality is configured and # running - if (!check_network($printer, $in, $upNetwork, 0)) { return 0 }; + if (!check_network($printer, $in, $upNetwork, 0)) { return 0 } # $in->set_help('setupLPD') if $::isInstall; my ($uri, $remotehost, $remotequeue); @@ -1536,7 +1536,7 @@ sub setup_smb { local $::isEmbedded = 0; # Check whether the network functionality is configured and # running - if (!check_network($printer, $in, $upNetwork, 0)) { return 0 }; + if (!check_network($printer, $in, $upNetwork, 0)) { return 0 } # $in->set_help('setupSMB') if $::isInstall; my ($uri, $smbuser, $smbpassword, $workgroup, $smbserver, $smbserverip, $smbshare); @@ -1544,7 +1544,7 @@ sub setup_smb { if ($printer->{configured}{$queue} && $printer->{currentqueue}{connect} =~ m/^smb:/) { $uri = $printer->{currentqueue}{connect}; - my $parameters = $1 if $uri =~ m!^\s*smb://(.*)$!; + my $parameters = $uri =~ m!^\s*smb://(.*)$! && $1; # Get the user's login and password from the URI if ($parameters =~ m!([^@]*)@([^@]+)!) { my $login = $1; @@ -1638,7 +1638,7 @@ sub setup_smb { unshift(@menuentrieslist, $menustr); $menuchoice = $menustr; } - if ($#menuentrieslist < 0) { + if (@menuentrieslist < 1) { $autodetect = 0; } elsif ($menuchoice eq "") { $menuchoice = $menuentrieslist[0]; @@ -1743,7 +1743,7 @@ sub setup_ncp { local $::isEmbedded = 0; # Check whether the network functionality is configured and # running - if (!check_network($printer, $in, $upNetwork, 0)) { return 0 }; + if (!check_network($printer, $in, $upNetwork, 0)) { return 0 } # $in->set_help('setupNCP') if $::isInstall; my ($uri, $ncpuser, $ncppassword, $ncpserver, $ncpqueue); @@ -1818,7 +1818,7 @@ sub setup_socket { local $::isEmbedded = 0; # Check whether the network functionality is configured and # running - if (!check_network($printer, $in, $upNetwork, 0)) { return 0 }; + if (!check_network($printer, $in, $upNetwork, 0)) { return 0 } # $in->set_help('setupSocket') if $::isInstall; @@ -1895,7 +1895,7 @@ sub setup_socket { unshift(@menuentrieslist, $menustr); $menuchoice = $menustr; } - if ($#menuentrieslist < 0) { + if (@menuentrieslist < 1) { $autodetect = 0; } elsif ($menuchoice eq "") { $menuchoice = $menuentrieslist[0]; @@ -1969,7 +1969,7 @@ sub setup_socket { "nc") . " " . N("Aborting")); return 0; - } + }; } # Auto-detect printer model @@ -2185,8 +2185,8 @@ sub setup_common { $makemodel =~ /^\s*$/) { local $::isWizard = 0; if (!$printer->{noninteractive}) { - if (($device =~ m!/usb/!) && - ($printer->{SPOOLER} eq 'cups')) { + if ($device =~ m!/usb/! && + $printer->{SPOOLER} eq 'cups') { my $choice = $in->ask_from_list (N("Add a new printer"), N("On many HP printers there are special functions available, maintenance (ink level checking, nozzle cleaning. head alignment, ...) on all not too old inkjets, scanning on multi-function devices, and memory card access on printers with card readers. ") . @@ -2223,7 +2223,7 @@ sub setup_common { $hplipinstallfailed = 1; } else { $w = $in->wait_message(N("Printerdrake"), - N("Installing %s package...",N("HPLIP"))) + N("Installing %s package...", N("HPLIP"))) if !$printer->{noninteractive}; $in->do_pkgs->install('hplip') or do { @@ -2255,15 +2255,15 @@ sub setup_common { undef $w; $w = $in->wait_message( N("Printerdrake"), - N("Checking device and configuring %s...",N("HPLIP"))) + N("Checking device and configuring %s...", N("HPLIP"))) if !$printer->{noninteractive}; if (!$hplipinstallfailed) { if ($isHPLIP) { my @uris = printer::main::start_hplip_manual(); - my @menu; my %menuhash; - for my $item (@uris) { - if ($item =~ m!^hp:/(usb|par|net)/(\S*?)(\?\S*|)$!){ + my (@menu, %menuhash); + foreach my $item (@uris) { + if ($item =~ m!^hp:/(usb|par|net)/(\S*?)(\?\S*|)$!) { my $modelname = "HP " . $2; $modelname =~ s/_/ /g; push(@menu, $modelname); @@ -2355,7 +2355,7 @@ sub setup_common { $hpojinstallfailed = 1; } else { $w = $in->wait_message(N("Printerdrake"), - N("Installing %s package...",N("HPOJ"))) + N("Installing %s package...", N("HPOJ"))) if !$printer->{noninteractive}; $in->do_pkgs->install('hpoj', 'xojpanel', 'usbutils') or do { @@ -2372,7 +2372,7 @@ sub setup_common { undef $w; $w = $in->wait_message (N("Printerdrake"), - N("Checking device and configuring %s...",N("HPOJ"))) + N("Checking device and configuring %s...", N("HPOJ"))) if !$printer->{noninteractive}; eval { $ptaldevice = printer::main::configure_hpoj @@ -2735,7 +2735,7 @@ sub setup_common { $descr !~ /$guessedmake/i && ($guessedmake ne "hp" || $descr !~ /Hewlett[\s-]+Packard/i)) - { $printer->{DBENTRY} = "" }; + { $printer->{DBENTRY} = "" } } } @@ -2891,7 +2891,7 @@ sub get_db_entry { if ($matchstr !~ /$guessedmake/i && ($guessedmake ne "hp" || $matchstr !~ /Hewlett[\s-]+Packard/i)) - { $printer->{DBENTRY} = "" }; + { $printer->{DBENTRY} = "" } } if ($printer->{DBENTRY} eq "") { # Set the OLD_CHOICE to a non-existing value @@ -3335,7 +3335,7 @@ sub unhexify { my $output = ""; my $hexmode = 0; my $firstdigit = ""; - for (my $i = 0; $i < length($input); $i ++) { + for (my $i = 0; $i < length($input); $i++) { my $c = substr($input, $i, 1); if ($hexmode) { if ($c eq ">") { @@ -4311,15 +4311,15 @@ sub install_spooler { # Install all packages needed to run printerdrake and the chosen spooler $packages = $spoolers{$spooler}{packages2add}; - push (@{$packages->[0]}, @{$commonpackages->[0]}); - push (@{$packages->[0]}, @{$localqueuepackages->[0]}) if + push @{$packages->[0]}, @{$commonpackages->[0]}; + push @{$packages->[0]}, @{$localqueuepackages->[0]} if $spoolers{$spooler}{local_queues}; - push (@{$packages->[1]}, @{$commonpackages->[1]}); - push (@{$packages->[1]}, @{$localqueuepackages->[1]}) if + push @{$packages->[1]}, @{$commonpackages->[1]}; + push @{$packages->[1]}, @{$localqueuepackages->[1]} if $spoolers{$spooler}{local_queues}; if (files_exist("/usr/bin/gimp") || files_exist("/usr/bin/gimp-2.2")) { - push (@{$packages->[0]}, @{$gimpprintingpackages->[0]}); - push (@{$packages->[1]}, @{$gimpprintingpackages->[1]}); + push @{$packages->[0]}, @{$gimpprintingpackages->[0]}; + push @{$packages->[1]}, @{$gimpprintingpackages->[1]}; } if (@{$packages->[0]} && !files_exist(@{$packages->[1]})) { undef $w; @@ -4396,7 +4396,7 @@ sub assure_remote_server_is_set { if (!$in->ask_from_ ({ title => N("Remote CUPS server and no local CUPS daemon"), messages => N("In this mode there is no local printing system, all printing requests go directly to the server specified below. Note that it is not possible to define local print queues then and if the specified server is down it cannot be printed at all from this machine.") . - "\n\n". + "\n\n" . N("Enter the host name or IP of your CUPS server and click OK if you want to use this mode, click \"Quit\" otherwise."), cancel => N("Quit"), callbacks => { @@ -4481,7 +4481,7 @@ sub set_cups_daemon_mode { type => 'list', sort => 0, list => [ N("Local CUPS printing system"), - N("Remote server, specify Name or IP here:") ]}, + N("Remote server, specify Name or IP here:") ] }, { val => \$remote_cups_server, disabled => sub { $modechoice ne @@ -4608,7 +4608,7 @@ sub wizard_close { undef $::isWizard; $::WizardWindow->destroy if defined $::WizardWindow; undef $::WizardWindow; -}; +} #- Program entry point for configuration of the printing system. sub main { @@ -4760,7 +4760,7 @@ sub mainwindow_interactive { $cursorpos = $printer->{configured}{$printer->{DEFAULT}}{queuedata}{menuentry} . N(" (Default)"); } elsif (($printer->{SPOOLER} eq "cups") || - ($printer->{SPOOLER} eq "rcups")){ + ($printer->{SPOOLER} eq "rcups")) { $cursorpos = find { /!$printer->{DEFAULT}:[^!]*$/ } printer::cups::get_formatted_remote_queues($printer); } } @@ -4843,7 +4843,7 @@ sub mainwindow_interactive { # Save the cursor position $cursorpos = $menuchoice; $menuchoice = '@usermode'; - 1 + 1; }, val => ($printer->{expert} ? N("Normal Mode") : N("Expert Mode")) }, @@ -5035,7 +5035,7 @@ sub add_printer { goto step_5 if $printer->{expert} || $printer->{MANUAL}; goto step_4 if $printer->{MANUALMODEL}; goto step_3_9; - } + }; } configure_queue($printer, $in) or die 'wizcancel'; undef $printer->{MANUAL} if $printer->{MANUAL}; @@ -5100,7 +5100,7 @@ sub add_printer { edit_printer($printer, $in, $upNetwork, $queue); return 1; } - }; + } # Delete some variables cleanup($printer); @@ -5362,6 +5362,6 @@ sub final_cleanup { delete($printer->{configured}{$queue}{queuedata}{menuentry}); } foreach (qw(Old_queue OLD_QUEUE QUEUE TYPE str_type currentqueue DBENTRY ARGS complete OLD_CHOICE NEW MORETHANONE MANUALMODEL AUTODETECT AUTODETECTLOCAL AUTODETECTNETWORK AUTODETECTSMB CONFIGLPD noninteractive expert)) - { delete $printer->{$_} }; + { delete $printer->{$_} } } diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm index b85d6e440..fafd36d60 100755 --- a/perl-install/scanner.pm +++ b/perl-install/scanner.pm @@ -152,11 +152,11 @@ sub configured() { port => $port, val => { DESCRIPTION => $description, - ($backend ? ( BACKEND => $backend ) : ()), + ($backend ? (BACKEND => $backend) : ()), ($firmwareline ? - ( FIRMWARELINE => $firmwareline ) : ()), + (FIRMWARELINE => $firmwareline) : ()), } - } + }; } } close LIST; @@ -207,8 +207,8 @@ sub nonroot_access_for_parport { # Modify /etc/xinetd.d/saned to let saned run as root my @sanedxinetdconf = cat_("/etc/xinetd.d/saned"); - ( s/(user\s*=\s*).*$/$1root/ ) foreach @sanedxinetdconf; - ( s/(group\s*=\s*).*$/$1root/ ) foreach @sanedxinetdconf; + s/(user\s*=\s*).*$/$1root/ foreach @sanedxinetdconf; + s/(group\s*=\s*).*$/$1root/ foreach @sanedxinetdconf; output("/etc/xinetd.d/saned", @sanedxinetdconf); # Read list of hosts to where to export the local scanners @@ -241,8 +241,8 @@ sub nonroot_access_for_parport { if (-r "/etc/xinetd.d/saned") { # Modify /etc/xinetd.d/saned to let saned run as saned my @sanedxinetdconf = cat_("/etc/xinetd.d/saned"); - ( s/(user\s*=\s*).*$/$1saned/ ) foreach @sanedxinetdconf; - ( s/(group\s*=\s*).*$/$1saned/ ) foreach @sanedxinetdconf; + s/(user\s*=\s*).*$/$1saned/ foreach @sanedxinetdconf; + s/(group\s*=\s*).*$/$1saned/ foreach @sanedxinetdconf; output("/etc/xinetd.d/saned", @sanedxinetdconf); # Restart xinetd services::restart("xinetd") if $sanedrunning; @@ -284,7 +284,7 @@ sub detect { my ($device) = grep { sprintf("%04x", $_->{vendor}) eq $vendor && sprintf("%04x", $_->{id}) eq $id } @devices; if ($device) { - $driver = $device->{driver} + $driver = $device->{driver}; } else { warn "i failled to lookupp $vendorid && $productid"; } -- cgit v1.2.1