From 00c1580ba28522496f321045b20ac34b433dd438 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 13 Jan 2003 09:04:09 +0000 Subject: make get_descr_from_ppd() clearer by : - using cat_() instead of manual open or ... - using "$var = s/$regexp//" instead of "var=/regexp\(...\)/; var=$1;" --- perl-install/printer/main.pm | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index d65c7044b..b45e1f7da 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -1397,14 +1397,14 @@ sub get_descr_from_ppd { my %ppd; #- if there is no ppd, this means this is a raw queue. - local *F; open F, "$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd" or return "|" . N("Unknown model"); - # "OTHERS|Generic PostScript printer|PostScript (en)"; - local $_; - while () { - /^\*([^\s:]*)\s*:\s*\"([^\"]*)\"/ and do { $ppd{$1} = $2; next }; - /^\*([^\s:]*)\s*:\s*([^\s\"]*)/ and do { $ppd{$1} = $2; next }; - } - close F; + eval { + local $_; + foreach (cat_("$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd")) { + # "OTHERS|Generic PostScript printer|PostScript (en)"; + /^\*([^\s:]*)\s*:\s*\"([^\"]*)\"/ and do { $ppd{$1} = $2; next }; + /^\*([^\s:]*)\s*:\s*([^\s\"]*)/ and do { $ppd{$1} = $2; next }; + } + } or return "|" . N("Unknown model"); my $descr = ($ppd{NickName} || $ppd{ShortNickName} || $ppd{ModelName}); # Apply the beautifying rules of poll_ppd_base @@ -1435,9 +1435,7 @@ sub get_descr_from_ppd { my $lang = $ppd{LanguageVersion}; # Remove manufacturer's name from the beginning of the model name - if ($make && $model =~ /^$make[\s\-]+([^\s\-].*)$/) { - $model = $1; - } + $model = s/^$make[\s\-]+// if $make; # Put out the resulting description string uc($make) . '|' . $model . '|' . $driver . -- cgit v1.2.1