summaryrefslogtreecommitdiffstats
path: root/perl-install/printer
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-01-13 09:04:09 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-01-13 09:04:09 +0000
commit00c1580ba28522496f321045b20ac34b433dd438 (patch)
tree29f6edcfcf73ce7cfa1a5b59ae3607ad7c38768e /perl-install/printer
parent436d82157496aa9e025492cb77f9fd73ee42f2cb (diff)
downloaddrakx-00c1580ba28522496f321045b20ac34b433dd438.tar
drakx-00c1580ba28522496f321045b20ac34b433dd438.tar.gz
drakx-00c1580ba28522496f321045b20ac34b433dd438.tar.bz2
drakx-00c1580ba28522496f321045b20ac34b433dd438.tar.xz
drakx-00c1580ba28522496f321045b20ac34b433dd438.zip
make get_descr_from_ppd() clearer by :
- using cat_() instead of manual open or ... - using "$var = s/$regexp//" instead of "var=/regexp\(...\)/; var=$1;"
Diffstat (limited to 'perl-install/printer')
-rw-r--r--perl-install/printer/main.pm20
1 files 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 (<F>) {
- /^\*([^\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 .