summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-12-03 14:12:09 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-12-03 14:12:09 +0000
commit0e49b4b5057a47c9969610226e0d88c6e8ceea47 (patch)
tree807e7a30d14222bf6000b2c24d2701006603f5d2 /perl-install
parent26d3c3daae6be35438706677b775e653df556e44 (diff)
downloaddrakx-backup-do-not-use-0e49b4b5057a47c9969610226e0d88c6e8ceea47.tar
drakx-backup-do-not-use-0e49b4b5057a47c9969610226e0d88c6e8ceea47.tar.gz
drakx-backup-do-not-use-0e49b4b5057a47c9969610226e0d88c6e8ceea47.tar.bz2
drakx-backup-do-not-use-0e49b4b5057a47c9969610226e0d88c6e8ceea47.tar.xz
drakx-backup-do-not-use-0e49b4b5057a47c9969610226e0d88c6e8ceea47.zip
do not use "local *F", use "my $F" or output() instead
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_any.pm19
-rw-r--r--perl-install/partition_table.pm4
-rwxr-xr-xperl-install/scanner.pm30
-rw-r--r--perl-install/timezone.pm7
4 files changed, 25 insertions, 35 deletions
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 700041382..014dea3e5 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -135,9 +135,9 @@ sub getAndSaveFile {
my ($file, $local) = @_ == 1 ? ("Mandrake/mdkinst$_[0]", $_[0]) : @_;
local $/ = \ (16 * 1024);
my $f = ref($file) ? $file : getFile($file) or return;
- local *F; open F, ">$local" or return;
+ open(my $F, ">$local") or return;
local $_;
- while (<$f>) { syswrite F, $_ }
+ while (<$f>) { syswrite $F, $_ }
1;
}
@@ -586,8 +586,7 @@ sub install_urpmi {
my $name = $_->{fakemedium};
if ($_->{ignored} || $_->{selected}) {
my $mask = umask 077;
- local *LIST;
- open LIST, ">$prefix/var/lib/urpmi/list.$name" or log::l("failed to write list.$name");
+ open(my $LIST, ">$prefix/var/lib/urpmi/list.$name") or log::l("failed to write list.$name");
umask $mask;
my $dir = ($_->{prefix} || ${{ nfs => "file://mnt/nfs",
@@ -603,18 +602,18 @@ sub install_urpmi {
#- WARNING this method of build only works because synthesis (or hdlist)
#- has been read.
foreach (@{$packages->{depslist}}[$_->{start} .. $_->{end}]) {
- print LIST "$dir/".$_->filename."\n";
+ print $LIST "$dir/".$_->filename."\n";
}
} else {
#- need to use another method here to build synthesis.
- local *F; open F, "parsehdlist '$prefix/var/lib/urpmi/hdlist.$name.cz' |";
+ open(my $F, "parsehdlist '$prefix/var/lib/urpmi/hdlist.$name.cz' |");
local $_;
- while (<F>) {
- print LIST "$dir/$_";
+ while (<$F>) {
+ print $LIST "$dir/$_";
}
- close F;
+ close $F;
}
- close LIST;
+ close $LIST;
#- build synthesis file if there are still not existing (ie not copied from mirror).
if (-s "$prefix/var/lib/urpmi/synthesis.hdlist.$name.cz" <= 32) {
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index d491af579..ffdaf9c74 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -793,8 +793,6 @@ sub save {
my ($hd, $file) = @_;
my @h = @{$hd}{@fields2save};
require Data::Dumper;
- local *F;
- open F, ">$file"
- and print F Data::Dumper->Dump([\@h], ['$h']), "\0"
+ eval { output($file, Data::Dumper->Dump([\@h], ['$h']), "\0") }
or die N("Error writing to file %s", $file);
}
diff --git a/perl-install/scanner.pm b/perl-install/scanner.pm
index 8eef579ff..f9f743b57 100755
--- a/perl-install/scanner.pm
+++ b/perl-install/scanner.pm
@@ -46,10 +46,7 @@ sub confScanner {
sub add2dll {
return if member($_[0], chomp_(cat_("$_sanedir/dll.conf")));
- local *F;
- open F, ">>$_sanedir/dll.conf" or die "can't write SANE config in $_sanedir/dll.conf: $!";
- print F "$_[0]\n";
- close F;
+ append_to_file("$_sanedir/dll.conf", "$_[0]\n");
}
sub detect {
@@ -123,9 +120,7 @@ sub readScannerDB {
sub updateScannerDBfromUsbtable {
substInFile { s/END// } "ScannerDB";
- local *F;
- open F, ">>ScannerDB" or die "can't write ScannerDB config in ScannerDB: $!";
- print F "# generated from usbtable by scannerdrake\n";
+ my $to_add = "# generated from usbtable by scannerdrake\n";
foreach (cat_("$ENV{SHARE_PATH}/ldetect-lst/usbtable")) {
my ($vendor_id, $product_id, $mod, $name) = chomp_(split /\s/,$_,4);
next if $mod ne '"scanner"';
@@ -134,19 +129,18 @@ sub updateScannerDBfromUsbtable {
print "#[$name] already in ScannerDB!\n";
next;
}
- print F "NAME $name\nDRIVER usb\nCOMMENT usb $vendor_id $product_id\nUNSUPPORTED\n\n";
+ $to_add .= "NAME $name\nDRIVER usb\nCOMMENT usb $vendor_id $product_id\nUNSUPPORTED\n\n";
}
- print F "END\n";
- close F;
+ $to_add .= "END\n";
+
+ append_to_file("ScannerDB", $to_add);
}
sub updateScannerDBfromSane {
my ($_sanesrcdir) = @_;
substInFile { s/END// } "ScannerDB";
- local *Y;
- open Y, ">>ScannerDB" or die "can't write ScannerDB config in ScannerDB: $!";
- print Y "# generated from Sane by scannerdrake\n";
+ my $to_add = "# generated from Sane by scannerdrake\n";
# for compat with our usbtable
my $sane2DB = {
"Acer" => "Acer Peripherals Inc.",
@@ -170,7 +164,7 @@ sub updateScannerDBfromSane {
foreach my $f (glob_("$_sanesrcdir/*.desc")) {
my $F = common::openFileMaybeCompressed($f);
- print Y "\n# from $f";
+ $to_add .= "\n# from $f";
my ($lineno, $cmd, $val) = 0;
my ($name, $intf, $comment, $mfg, $backend);
my $fs = {
@@ -183,8 +177,8 @@ sub updateScannerDBfromSane {
if (member($name, keys %$scanner::scannerDB)) {
print "#[$name] already in ScannerDB!\n";
} else {
- print Y "\nNAME $name\nSERVER $backend\nDRIVER $intf\n";
- print Y "COMMENT $comment\n" if $comment;
+ $to_add .= "\nNAME $name\nSERVER $backend\nDRIVER $intf\n";
+ $to_add .= "COMMENT $comment\n" if $comment;
$comment = undef;
}
$name = $val;
@@ -202,8 +196,8 @@ sub updateScannerDBfromSane {
}
$fs->{model}(); # the last one
}
- print Y "\nEND\n";
- close Y;
+ $to_add .= "\nEND\n";
+ append_to_file("ScannerDB", $to_add);
}
1; #
diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm
index 9c8d10521..be6899975 100644
--- a/perl-install/timezone.pm
+++ b/perl-install/timezone.pm
@@ -9,10 +9,9 @@ use log;
sub getTimeZones {
my ($prefix) = @_;
- local *F;
- open F, "cd $prefix/usr/share/zoneinfo && find [A-Z]* -type f |";
- my @l = chomp_(<F>);
- close F or die "cannot list the available zoneinfos";
+ open(my $F, "cd $prefix/usr/share/zoneinfo && find [A-Z]* -type f |");
+ my @l = chomp_(<$F>);
+ close $F or die "cannot list the available zoneinfos";
sort @l;
}