diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-13 10:05:31 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2002-11-13 10:05:31 +0000 |
commit | f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369 (patch) | |
tree | a484ace4d32ce86b3eafefe8751688baf439f174 /perl-install/printer/common.pm | |
parent | 34f0f51bffcf355124797ec6ad1cb263921e47c4 (diff) | |
download | drakx-backup-do-not-use-f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369.tar drakx-backup-do-not-use-f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369.tar.gz drakx-backup-do-not-use-f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369.tar.bz2 drakx-backup-do-not-use-f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369.tar.xz drakx-backup-do-not-use-f3274ad01b2b1d7e84b6a2c26ce03f605b0b7369.zip |
printer::common: export function
Diffstat (limited to 'perl-install/printer/common.pm')
-rw-r--r-- | perl-install/printer/common.pm | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/perl-install/printer/common.pm b/perl-install/printer/common.pm index 13e5919f9..5e65340d5 100644 --- a/perl-install/printer/common.pm +++ b/perl-install/printer/common.pm @@ -1,6 +1,10 @@ package printer::common; use strict; +use vars qw(@ISA @EXPORT); + +@ISA = qw(Exporter); +@EXPORT = qw(addentry addsection removeentry removesection); sub addentry { @@ -10,9 +14,7 @@ sub addentry { my @lines = split("\n", $filecontent); foreach (@lines) { if (!$sectionfound) { - if (/^\s*\[\s*$section\s*\]\s*$/) { - $sectionfound = 1; - } + $sectionfound = 1 if /^\s*\[\s*$section\s*\]\s*$/; } else { if (!/^\s*$/ && !/^\s*;/) { #-# $_ = "$entry\n$_"; @@ -21,9 +23,7 @@ sub addentry { } } } - if ($sectionfound && !$entryinserted) { - push(@lines, $entry); - } + push(@lines, $entry) if $sectionfound && !$entryinserted; return join ("\n", @lines); } @@ -32,10 +32,8 @@ sub addsection { my $entryinserted = 0; my @lines = split("\n", $filecontent); foreach (@lines) { - if (/^\s*\[\s*$section\s*\]\s*$/) { - # section already there, nothing to be done - return $filecontent; - } + # section already there, nothing to be done + return $filecontent if /^\s*\[\s*$section\s*\]\s*$/; } return $filecontent . "\n[$section]"; } @@ -49,8 +47,7 @@ sub removeentry { $_ = "$_\n"; next if $done; if (!$sectionfound) { - if (/^\s*\[\s*$section\s*\]\s*$/) { - $sectionfound = 1; + $sectionfound = 1 if /^\s*\[\s*$section\s*\]\s*$/; } } else { if (/^\s*\[.*\]\s*$/) { # Next section |