diff options
34 files changed, 96 insertions, 101 deletions
diff --git a/perl-install/Xconfig/card.pm b/perl-install/Xconfig/card.pm index ece4ef2cb..f90e1cf3a 100644 --- a/perl-install/Xconfig/card.pm +++ b/perl-install/Xconfig/card.pm @@ -84,8 +84,8 @@ sub from_raw_X { my ($xfree3_server) = readlink("$::prefix/etc/X11/X") =~ /XF86_(.*)/; my $card = { - use_UTAH_GLX => int(grep { /glx/ } $raw_X->{xfree3}->get_modules), - use_DRI_GLX => int(grep { /dri/ } $raw_X->{xfree4}->get_modules), + use_UTAH_GLX => any { /glx/ } $raw_X->{xfree3}->get_modules, + use_DRI_GLX => any { /dri/ } $raw_X->{xfree4}->get_modules), server => $xfree3_server, prefer_xf3 => $xfree3_server && !$force_xf4, %$device, @@ -284,7 +284,7 @@ sub configure { $card->{prog} = install_server($card, $options, $do_pkgs); if ($card->{needVideoRam} && !$card->{VideoRam}) { - $card->{VideoRam} = first(grep { $_ <= $options->{VideoRam_probed} } reverse ikeys %VideoRams) || 4096; + $card->{VideoRam} = (find { $_ <= $options->{VideoRam_probed} } reverse ikeys %VideoRams) || 4096; $in->ask_from('', N("Select the memory size of your graphics card"), [ { val => \$card->{VideoRam}, type => 'list', @@ -361,7 +361,7 @@ sub multi_head_choices { my @choices; my $has_multi_head = @cards > 1 || $cards[0]{MULTI_HEAD} > 1; - my $disable_multi_head = grep { + my $disable_multi_head = any { $_->{Driver} or log::l("found card $_->{description} not supported by XF4, disabling multi-head support"); !$_->{Driver}; } @cards; diff --git a/perl-install/Xconfig/monitor.pm b/perl-install/Xconfig/monitor.pm index 3d9415dff..8ca3ba935 100644 --- a/perl-install/Xconfig/monitor.pm +++ b/perl-install/Xconfig/monitor.pm @@ -133,7 +133,7 @@ sub configure_automatic { if ($monitor->{EISA_ID}) { log::l("EISA_ID: $monitor->{EISA_ID}"); - if (my ($mon) = grep { lc($_->{EISA_ID}) eq $monitor->{EISA_ID} } @$monitors) { + if (my $mon = find { lc($_->{EISA_ID}) eq $monitor->{EISA_ID} } @$monitors) { add2hash($monitor, $mon); log::l("EISA_ID corresponds to: $monitor->{ModelName}"); } elsif (!$monitor->{HorizSync} || !$monitor->{VertRefresh}) { @@ -141,7 +141,7 @@ sub configure_automatic { delete @$monitor{'VendorName', 'ModelName', 'EISA_ID'}; } } else { - if (my ($mon) = grep { $_->{VendorName} eq $monitor->{VendorName} && $_->{ModelName} eq $monitor->{ModelName} } @$monitors) { + if (my $mon = find { $_->{VendorName} eq $monitor->{VendorName} && $_->{ModelName} eq $monitor->{ModelName} } @$monitors) { put_in_hash($monitor, $mon); } } diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm index 1461f64be..ea859b5c7 100644 --- a/perl-install/Xconfig/resolution_and_depth.pm +++ b/perl-install/Xconfig/resolution_and_depth.pm @@ -163,7 +163,7 @@ sub choices { #- finding it in @resolutions (well @matching) #- (that way, we check it exists, and we get field "bios" for fbdev) my @default_resolutions = sort { $b->{Y} <=> $a->{Y} } grep { $_->{Depth} eq $Depth } @matching; - my $default_resolution = first(grep { $resolution_wanted->{Y} eq $_->{Y} } @default_resolutions) || $default_resolutions[0]; + my $default_resolution = (find { $resolution_wanted->{Y} eq $_->{Y} } @default_resolutions) || $default_resolutions[0]; $default_resolution, @resolutions; } @@ -243,7 +243,7 @@ sub choose_gtk { $chosen_y_res = $_[1]; } else { #- take one - my ($one) = grep { $_->{X} eq $chosen_x_res } @resolutions; + my $one = find { $_->{X} eq $chosen_x_res } @resolutions; $chosen_y_res = $one->{Y}; } my $image = $monitor_images_x_res{$chosen_x_res} or internal_error("no image for resolution $chosen_x_res"); @@ -303,9 +303,9 @@ sub choose_gtk { $x_res_combo->entry->set_text($chosen_x_res . "x" . $chosen_y_res); $W->main or return; - first(grep { $_->{X} == $chosen_x_res && - $_->{Y} == $chosen_y_res && - $_->{Depth} == $chosen_Depth } @resolutions); + find { $_->{X} == $chosen_x_res && + $_->{Y} == $chosen_y_res && + $_->{Depth} == $chosen_Depth } @resolutions); } 1; diff --git a/perl-install/Xconfig/xfreeX.pm b/perl-install/Xconfig/xfreeX.pm index 5853342f9..8351c5685 100644 --- a/perl-install/Xconfig/xfreeX.pm +++ b/perl-install/Xconfig/xfreeX.pm @@ -118,9 +118,8 @@ sub get_screens { sub get_default_screen { my ($raw_X) = @_; my @l = get_screens($raw_X); - my @m = grep { $_->{Identifier} && val($_->{Identifier}) eq 'screen1' || - $_->{Driver} && val($_->{Driver}) =~ /svga|accel/ } @l; - first(@m ? @m : @l); + (find { $_->{Identifier} && val($_->{Identifier}) eq 'screen1' || + $_->{Driver} && val($_->{Driver}) =~ /svga|accel/ } @l) || $l[0]; } sub set_screens { my ($raw_X, @screens) = @_; @@ -172,7 +171,7 @@ sub get_resolution { $Screen ||= $raw_X->get_default_screen or return {}; my $depth = val($Screen->{DefaultColorDepth}); - my ($Display) = grep { !$depth || val($_->{l}{Depth}) eq $depth } @{$Screen->{Display} || []} or return {}; + my $Display = find { !$depth || val($_->{l}{Depth}) eq $depth } @{$Screen->{Display} || []} or return {}; val($Display->{l}{Modes}) =~ /(\d+)x(\d+)/ or return {}; { X => $1, Y => $2, Depth => val($Display->{l}{Depth}) }; } diff --git a/perl-install/any.pm b/perl-install/any.pm index 267e91673..e08924bab 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -167,7 +167,7 @@ sub setupBootloader__general { ($b->{method}, my $method_choices) = bootloader::method_choices($fstab); my $profiles = bootloader::has_profiles($b); my $memsize = bootloader::get_append($b, 'mem'); - my $prev_clean_tmp = my $clean_tmp = grep { $_->{mntpoint} eq '/tmp' } @{$all_hds->{special} ||= []}; + my $prev_clean_tmp = my $clean_tmp = any { $_->{mntpoint} eq '/tmp' } @{$all_hds->{special} ||= []}; my $prev_boot = $b->{boot}; $b->{password2} ||= $b->{password} ||= ''; diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index b67d8dabe..13d6b2be9 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -842,7 +842,7 @@ sub write_lilo_conf { print F "message=/boot/message" if arch() !~ /ia64/; print F "menu-scheme=wb:bw:wb:bw" if arch() !~ /ia64/; - print F "ignore-table" if grep { $_->{unsafe} && $_->{table} } @{$bootloader->{entries}}; + print F "ignore-table" if any { $_->{unsafe} && $_->{table} } @{$bootloader->{entries}}; while (my ($dev, $bios) = each %{$bootloader->{bios}}) { print F "disk=$dev bios=$bios"; @@ -1051,7 +1051,7 @@ sub lnx4win_file { sub install { my ($bootloader, $fstab, $hds) = @_; - if (my ($p) = grep { $bootloader->{boot} eq "/dev/$_->{device}" } @$fstab) { + if (my $p = find { $bootloader->{boot} eq "/dev/$_->{device}" } @$fstab) { die N("You can't install the bootloader on a %s partition\n", partition_table::type2fs($p)) if isThisFs('xfs', $p); } diff --git a/perl-install/common.pm b/perl-install/common.pm index f44a0c0bf..3948cf7f9 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -72,7 +72,7 @@ sub availableRamMB() { my $s = MDK::Common::System::availableRamMB(); #- HACK HACK: if i810 and memsize require detect_devices; - return $s - 1 if $s == 128 && grep { $_->{driver} eq 'Card:Intel 810' } detect_devices::probeall(); + return $s - 1 if $s == 128 && any { $_->{driver} eq 'Card:Intel 810' } detect_devices::probeall(); $s; } @@ -128,7 +128,7 @@ sub formatTime { } } -sub usingRamdisk { scalar(grep { /ram3/ } cat_("/proc/mounts")) } +sub usingRamdisk { any { /ram3/ } cat_("/proc/mounts") } sub expand_symlinks_but_simple { my ($f) = @_; diff --git a/perl-install/detect_devices.pm b/perl-install/detect_devices.pm index d4221ae1c..aaf375b86 100644 --- a/perl-install/detect_devices.pm +++ b/perl-install/detect_devices.pm @@ -113,7 +113,7 @@ sub get_sys_cdrom_info { @drives_order = map { s/^sr/scd/; my $dev = $_; - first(grep { $_->{device} eq $dev } @drives); + find { $_->{device} eq $dev } @drives; } @l; } else { my $capacity; @@ -160,7 +160,7 @@ sub get_usb_storage_info { @informed or return; foreach my $usb (usb_probe()) { - if (my ($e) = grep { $_->{usb_vendor} == $usb->{vendor} && $_->{usb_id} == $usb->{id} } @informed) { + if (my $e = find { $_->{usb_vendor} == $usb->{vendor} && $_->{usb_id} == $usb->{id} } @informed) { $e->{"usb_$_"} = $usb->{$_} foreach keys %$usb; } } @@ -731,7 +731,7 @@ sub raidAutoStartRaidtab { #- (choosing any inactive md) raid::inactivate_all(); foreach (@parts) { - my ($nb) = grep { !raid::is_active("md$_") } 0..7; + my $nb = find { !raid::is_active("md$_") } 0..7; output("/tmp/raidtab", "raiddev /dev/md$nb\n device " . devices::make($_->{device}) . "\n"); run_program::run('raidstart', '-c', "/tmp/raidtab", devices::make("md$nb")); } diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm index 41df6a5f9..f065eac0f 100644 --- a/perl-install/diskdrake/hd_gtk.pm +++ b/perl-install/diskdrake/hd_gtk.pm @@ -246,7 +246,7 @@ sub create_automatic_notebooks { }; $may_add->(hd2kind($_)) foreach @{$all_hds->{hds}}; $may_add->(lvm2kind($_)) foreach @{$all_hds->{lvms}}; - $may_add->(raid2kind()) if grep { $_ } @{$all_hds->{raids}}; + $may_add->(raid2kind()) if any { $_ } @{$all_hds->{raids}}; $may_add->(loopback2kind()) if @{$all_hds->{loopbacks}}; @notebook = grep_index { diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index e3055ca2a..04215eb07 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -798,9 +798,8 @@ sub RemoveFromLVM { my ($_in, $_hd, $part, $all_hds) = @_; my $lvms = $all_hds->{lvms}; isPartOfLVM($part) or die; - my ($lvm) = grep { $_->{VG_name} eq $part->{lvm} } @$lvms; - lvm::vg_destroy($lvm); - @$lvms = grep { $_ != $lvm } @$lvms; + (my $lvm, $lvms) = partition { $_->{VG_name} eq $part->{lvm} } @$lvms; + lvm::vg_destroy($lvm->[0]); } sub ModifyRAID { my ($in, $_hd, $part, $all_hds) = @_; @@ -920,7 +919,7 @@ sub Options { sub is_part_existing { my ($part, $all_hds) = @_; - $part && grep { fsedit::is_same_part($part, $_) } fsedit::get_all_fstab_and_holes($all_hds); + $part && any { fsedit::is_same_part($part, $_) } fsedit::get_all_fstab_and_holes($all_hds); } sub modifyRAID { diff --git a/perl-install/diskdrake/smbnfs_gtk.pm b/perl-install/diskdrake/smbnfs_gtk.pm index 7bf184afe..8a8feb8d3 100644 --- a/perl-install/diskdrake/smbnfs_gtk.pm +++ b/perl-install/diskdrake/smbnfs_gtk.pm @@ -119,7 +119,7 @@ sub find_fstab_entry { my $fs_entry = $kind->to_fstab_entry($e); - if (my ($fs_entry_) = grep { $fs_entry->{device} eq $_->{device} } @{$kind->{val}}) { + if (my $fs_entry_ = find { $fs_entry->{device} eq $_->{device} } @{$kind->{val}}) { $fs_entry_; } elsif ($add_or_not) { push @{$kind->{val}}, $fs_entry; diff --git a/perl-install/fs.pm b/perl-install/fs.pm index be5d5c889..48a66c265 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -72,7 +72,7 @@ sub read_fstab { }; if ($dev =~ /^LABEL=/) { - if (my ($e) = grep { $_->{mntpoint} eq $mntpoint } read_fstab('', '/proc/mounts')) { + if (my $e = find { $_->{mntpoint} eq $mntpoint } read_fstab('', '/proc/mounts')) { $h->{device_LABEL} = $dev; $dev = $h->{device} = $e->{device}; } @@ -112,8 +112,9 @@ sub merge_fstabs { my ($loose, $fstab, @l) = @_; foreach my $p (@$fstab) { - my ($p2) = grep { fsedit::is_same_hd($_, $p) } @l or next; - @l = grep { !fsedit::is_same_hd($_, $p) } @l; + my ($l1, $l2) = partition { fsedit::is_same_hd($_, $p) } @l; + my ($p2) = @$l1 or next; + @l = @$l2; $p->{mntpoint} = $p2->{mntpoint} if delete $p->{unsafeMntpoint}; @@ -536,7 +537,7 @@ sub format_ext2($@) { my ($dev, @options) = @_; $dev =~ m,(rd|ida|cciss)/, and push @options, qw(-b 4096 -R stride=16); #- For RAID only. push @options, qw(-b 1024 -O none) if arch() =~ /alpha/; - run_program::raw({ timeout => 60 * 60 }, 'mke2fs', '-F', @options, devices::make($dev)) or die N("%s formatting of %s failed", grep { $_ eq '-j' } @options ? "ext3" : "ext2", $dev); + run_program::raw({ timeout => 60 * 60 }, 'mke2fs', '-F', @options, devices::make($dev)) or die N("%s formatting of %s failed", any { $_ eq '-j' } @options ? "ext3" : "ext2", $dev); } sub format_ext3 { my ($dev, @options) = @_; @@ -596,7 +597,7 @@ sub real_format_part { } elsif (isAppleBootstrap($part)) { format_hfs($dev, @options, '-l', "bootstrap"); } elsif (isSwap($part)) { - my $check_blocks = grep { /^-c$/ } @options; + my $check_blocks = any { /^-c$/ } @options; swap::make($dev, $check_blocks); } else { die N("I don't know how to format %s in type %s", $part->{device}, type2name($part->{type})); diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index bd5597d7e..cc77b6c19 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -116,7 +116,7 @@ sub raids { my @mdparts = map { my $mdpart = $devname2part{$_} || { device => $_ }; - if (my ($part) = grep { is_same_hd($mdpart, $_) } @parts) { + if (my $part = find { is_same_hd($mdpart, $_) } @parts) { $part->{raid} = $nb; delete $part->{mntpoint}; $part; @@ -147,7 +147,7 @@ sub lvms { my @lvms; foreach (@pvs) { my $name = lvm::get_vg($_) or next; - my ($lvm) = grep { $_->{VG_name} eq $name } @lvms; + my $lvm = find { $_->{VG_name} eq $name } @lvms; if (!$lvm) { $lvm = new lvm($name); lvm::update_size($lvm); @@ -269,11 +269,11 @@ sub read_proc_partitions { my @parts = grep { $_->{dev} =~ /\d$/ } @all; my @disks = grep { $_->{dev} !~ /\d$/ } @all; - my $devfs_like = grep { $_->{dev} =~ m|/disc$| } @disks; + my $devfs_like = any { $_->{dev} =~ m|/disc$| } @disks; my %devfs2normal = map { my (undef, $major, $minor) = devices::entry($_->{device}); - my ($disk) = grep { $_->{major} == $major && $_->{minor} == $minor } @disks; + my $disk = find { $_->{major} == $major && $_->{minor} == $minor } @disks; $disk->{dev} => $_->{device}; } @$hds; @@ -305,7 +305,7 @@ sub all_hds { } sub part2hd { my ($part, $all_hds) = @_; - my ($hd) = grep { $part->{rootDevice} eq ($_->{device} || $_->{VG_name}) } all_hds($all_hds); + my $hd = find { $part->{rootDevice} eq ($_->{device} || $_->{VG_name}) } all_hds($all_hds); $hd; } @@ -400,7 +400,7 @@ sub file2part { $file = $keep_simple_symlinks ? common::expand_symlinks_but_simple("$::prefix$file") : expand_symlinks("$::prefix$file"); unless ($file =~ s/^$::prefix//) { - my ($part) = grep { loopback::carryRootLoopback($_) } @$fstab or die; + my $part = find { loopback::carryRootLoopback($_) } @$fstab or die; log::l("found $part->{mntpoint}"); $file =~ s|/initrd/loopfs|$part->{mntpoint}|; } @@ -449,14 +449,14 @@ sub computeSize { } my $size = int min($max, $best->{size} + $free_space * ($tot_ratios && $best->{ratio} / $tot_ratios)); #- verify other entry can fill the hole - if (grep { $_->{size} < $max - $size } @L) { $size } else { $max } + any { $_->{size} < $max - $size } @L ? $size : $max; } sub suggest_part { my ($part, $all_hds, $suggestions) = @_; $suggestions ||= $suggestions{server} || $suggestions{simple}; - my $has_swap = grep { isSwap($_) } get_all_fstab($all_hds); + my $has_swap = any { isSwap($_) } get_all_fstab($all_hds); my ($best) = grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} } @@ -483,7 +483,7 @@ sub suggestions_mntpoint { sub mntpoint2part { my ($mntpoint, $fstab) = @_; - first(grep { $mntpoint eq $_->{mntpoint} } @$fstab); + find { $mntpoint eq $_->{mntpoint} } @$fstab; } sub has_mntpoint { my ($mntpoint, $all_hds) = @_; @@ -589,7 +589,7 @@ sub auto_allocate { if ($before == listlength(fsedit::get_all_fstab($all_hds))) { # find out why auto_allocate failed - if (grep { !has_mntpoint($_->{mntpoint}, $all_hds) } @$suggestions_) { + if (any { !has_mntpoint($_->{mntpoint}, $all_hds) } @$suggestions_) { die N("Not enough free space for auto-allocating"); } else { die N("Nothing to do"); diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index da93883a2..352de196a 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -294,7 +294,7 @@ sub preConfigureTimezone { $o->{timezone}{timezone} ||= timezone::bestTimezone(lang::lang2text($o->{lang})); - my $utc = !grep { isFat($_) || isNT($_) } @{$o->{fstab}}; + my $utc = every { !isFat($_) && !isNT($_) } @{$o->{fstab}}; my $ntp = timezone::ntp_server($o->{prefix}); add2hash_($o->{timezone}, { UTC => $utc, ntp => $ntp }); } @@ -381,7 +381,7 @@ sub setDefaultPackages { $o->{compssUsersChoice}{HIGH_SECURITY} = 1 if $o->{security} > 3; $o->{compssUsersChoice}{BIGMEM} = 1 if !$::oem && availableRamMB() > 800 && arch() !~ /ia64/; $o->{compssUsersChoice}{SMP} = 1 if detect_devices::hasSMP(); - $o->{compssUsersChoice}{CDCOM} = 1 if grep { $_->{descr} =~ /commercial/i } values %{$o->{packages}{mediums}}; + $o->{compssUsersChoice}{CDCOM} = 1 if any { $_->{descr} =~ /commercial/i } values %{$o->{packages}{mediums}}; $o->{compssUsersChoice}{'3D'} = 1 if detect_devices::matching_desc('Matrox.* G[245][05]0') || detect_devices::matching_desc('Rage X[CL]') || @@ -940,9 +940,9 @@ sub guess_mount_point { my $handle = any::inspect($part, $prefix) or return; my $d = $handle->{dir}; - my ($mnt) = grep { -e "$d/$l{$_}" } keys %l; + my $mnt = find { -e "$d/$l{$_}" } keys %l; $mnt ||= (stat("$d/.bashrc"))[4] ? '/root' : '/home/user' . ++$$user if -e "$d/.bashrc"; - $mnt ||= (grep { -d $_ && (stat($_))[4] >= 500 && -e "$_/.bashrc" } glob_($d)) ? '/home' : ''; + $mnt ||= (any { -d $_ && (stat($_))[4] >= 500 && -e "$_/.bashrc" } glob_($d)) ? '/home' : ''; ($mnt, $handle); } @@ -1104,7 +1104,7 @@ sub check_prog { my @l = $f !~ m|^/| ? map { "$_/$f" } split(":", $ENV{PATH}) : $f; - return if grep { -x $_ } @l; + return if any { -x $_ } @l; common::usingRamdisk() or log::l("ERROR: check_prog can't find the program $f and we're not using ramdisk"), return; diff --git a/perl-install/install_gtk.pm b/perl-install/install_gtk.pm index 1539d7dd0..5f895a77c 100644 --- a/perl-install/install_gtk.pm +++ b/perl-install/install_gtk.pm @@ -19,7 +19,7 @@ my (@background1, @background2); sub load_rc { my ($name) = @_; - if (my ($f) = grep { -r $_ } map { "$_/$name.rc" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__))) { + if (my $f = find { -r $_ } map { "$_/$name.rc" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__))) { Gtk2::Rc->parse($f); foreach (cat_($f)) { if (/style\s+"background"/ .. /^\s*$/) { diff --git a/perl-install/install_interactive.pm b/perl-install/install_interactive.pm index 4d6329f60..0598340c4 100644 --- a/perl-install/install_interactive.pm +++ b/perl-install/install_interactive.pm @@ -64,7 +64,7 @@ sub partition_with_diskdrake { For this, create a partition (or click on an existing one). Then choose action ``Mount point'' and set it to `/'"), 1) or return; } - if (!grep { isSwap($_) } @fstab) { + if (!any { isSwap($_) } @fstab) { $o->ask_warn('', N("You must have a swap partition")), $ok = 0 if !$::expert; $ok &&= $o->ask_okcancel('', N("You don't have a swap partition.\n\nContinue anyway?")); } @@ -231,7 +231,7 @@ sub partitionWizard { if ($solutions{loopback}) { %solutions = (loopback => $solutions{loopback}); } else { - $o->ask_warn('', N("You don't have enough free space on your Windows partition")) if grep { isFat($_) } fsedit::get_all_fstab($o->{all_hds}); + $o->ask_warn('', N("You don't have enough free space on your Windows partition")) if any { isFat($_) } fsedit::get_all_fstab($o->{all_hds}); } } diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index 75e20fe77..8d61c58c2 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -186,7 +186,7 @@ sub doPartitionDisksAfter { } cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/image nfs| && - !grep { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and + !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and push @{$o->{all_hds}{nfss}}, { type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" }; } @@ -383,7 +383,7 @@ sub afterInstallPackages($) { die N("Some important packages didn't get installed properly. Either your cdrom drive or your cdrom is defective. Check the cdrom on an installed computer using \"rpm -qpl Mandrake/RPMS/*.rpm\" -") if grep { m|read failed: Input/output error| } cat_("$o->{prefix}/root/drakx/install.log"); +") if any { m|read failed: Input/output error| } cat_("$o->{prefix}/root/drakx/install.log"); if (arch() !~ /^sparc/) { #- TODO restore it as may be needed for sparc -x "$o->{prefix}/usr/bin/dumpkeys" or $::testing or die @@ -848,7 +848,7 @@ sub setupBootloaderBefore { ); #- propose the default fb mode for kernel fb, if aurora or bootsplash is installed. - my $need_fb = grep { + my $need_fb = any { my $p = pkgs::packageByName($o->{packages}, $_); $p && $p->flag_installed; } 'Aurora', 'bootsplash'; diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index e4aab7160..b7a4f60e1 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -285,7 +285,7 @@ sub choosePackagesTree { foreach my $p (@{$packages->{depslist}}) { !$limit_to_medium || pkgs::packageMedium($packages, $p) == $limit_to_medium or next; my @flags = $p->rflags; - next if !($p->rate && grep { grep { !/^!/ && $fl{$_} } split('\|\|') } @flags); + next if !($p->rate && any { any { !/^!/ && $fl{$_} } split('\|\|') } @flags); $p->rate >= 3 ? push(@firstchoice, $p->name) : push(@others, $p->name); diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index 9da09e9c8..dbd808969 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -289,7 +289,7 @@ sub choosePartitionsToFormat { } @$fstab; $_->{toFormat} = 1 foreach grep { isSwap($_) && !$::expert } @$fstab; - return if @l == 0 || !$::expert && 0 == grep { ! $_->{toFormat} } @l; + return if @l == 0 || !$::expert && every { $_->{toFormat} } @l; #- keep it temporary until the guy has accepted $_->{toFormatTmp} = $_->{toFormat} || $_->{toFormatUnsure} foreach @l; @@ -469,7 +469,7 @@ sub chooseGroups { int $total_size; }; my %val = map { - $_ => ! grep { ! $o->{compssUsersChoice}{$_} } @{$compssUsers->{$_}{flags}} + $_ => every { $o->{compssUsersChoice}{$_} } @{$compssUsers->{$_}{flags}} } @groups; # @groups = grep { $size{$_} = round_down($size{$_} / sqr(1024), 10) } @groups; #- don't display the empty or small one (eg: because all packages are below $min_level) @@ -505,9 +505,9 @@ sub chooseGroups { #- do not try to deselect package (by default no groups are selected). $o->{isUpgrade} or $unselect_all and install_any::unselectMostPackages($o); #- if no group have been chosen, ask for using base system only, or no X, or normal. - if (!$o->{isUpgrade} && !grep { $val{$_} } keys %val) { + if (!$o->{isUpgrade} && !any { $_ } values %val) { my $docs = !$o->{excludedocs}; - my $minimal = !grep { $_ } values %{$o->{compssUsersChoice}}; + my $minimal = !any { $_ } values %{$o->{compssUsersChoice}}; $o->ask_from(N("Type of install"), N("You haven't selected any group of packages. diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index a09f68f37..efc823418 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -306,7 +306,7 @@ sub ask_from_normalize { $e->{type} ||= 'combo'; if (!$e->{not_edit}) { - die q(when using "not_edit" you must use strings, not a data structure) if ref ${$e->{val}} || grep { ref $_ } @$li; + die q(when using "not_edit" you must use strings, not a data structure) if ref ${$e->{val}} || any { ref $_ } @$li; } if ($e->{type} ne 'combo' || $e->{not_edit}) { ${$e->{val}} = $li->[0] if !member(may_apply($e->{format}, ${$e->{val}}), map { may_apply($e->{format}, $_) } @$li); @@ -360,11 +360,11 @@ sub ask_from_ { sub ask_from_no_check { my ($o, $common, $l) = @_; ask_from_normalize($o, $common, $l); - $o->ask_fromW($common, [ grep { !$_->{advanced} } @$l ], [ grep { $_->{advanced} } @$l ]); + $o->ask_fromW($common, partition { !$_->{advanced} } @$l); } sub ask_from_real { my ($o, $common, $l) = @_; - my $v = $o->ask_fromW($common, [ grep { !$_->{advanced} } @$l ], [ grep { $_->{advanced} } @$l ]); + my $v = $o->ask_fromW($common, partition { !$_->{advanced} } @$l); %$common = (); $v; } diff --git a/perl-install/interactive/newt.pm b/perl-install/interactive/newt.pm index 5c531f1fc..4660b987b 100644 --- a/perl-install/interactive/newt.pm +++ b/perl-install/interactive/newt.pm @@ -62,7 +62,7 @@ sub checkval { $_[0] && $_[0] ne ' ' ? '*' : ' ' } sub ask_fromW { my ($o, $common, $l, $l2) = @_; - if (grep { $_->{type} ne 'button' } @$l or @$l < 5) { + if ((any { $_->{type} ne 'button' } @$l) || @$l < 5) { &ask_fromW_real; } else { my $r; @@ -220,7 +220,7 @@ sub ask_fromW_real { my $r = $form->RunForm; $canceled = $cancel && $$r == $$cancel; - if (my ($button) = grep { $$r == ${$_->{w}} } @widgets) { + if (my $button = find { $$r == ${$_->{w}} } @widgets) { $get_all->(); my $v = $button->{e}{clicked_may_quit}(); $form->FormDestroy; diff --git a/perl-install/lang.pm b/perl-install/lang.pm index d3ced6c9e..bdacc81e1 100644 --- a/perl-install/lang.pm +++ b/perl-install/lang.pm @@ -428,7 +428,7 @@ sub lang2country { $country ||= $valid_country->(lc($1)) if $lang =~ /([A-Z]+)/; $country ||= $valid_country->(lc($1)) if lang2LANGUAGE($lang) =~ /([A-Z]+)/; $country ||= $valid_country->(substr($lang, 0, 2)); - $country ||= first(grep { $valid_country->($_) } map { substr($_, 0, 2) } split(':', lang2LANGUAGE($lang))); + $country ||= find { $valid_country->($_) } map { substr($_, 0, 2) } split(':', lang2LANGUAGE($lang)); $country || 'C'; } @@ -441,10 +441,10 @@ sub country2lang { my ($lang1, $lang2); $lang1 ||= $country2lang{$country}; - $lang1 ||= first(grep { /^$country/ } list()); - $lang1 ||= first(grep { /_$uc_country/ } list()); - $lang2 ||= first(grep { int grep { /^$country/ } split(':', lang2LANGUAGE($_)) } list()); - $lang2 ||= first(grep { int grep { /_$uc_country/ } split(':', lang2LANGUAGE($_)) } list()); + $lang1 ||= find { /^$country/ } list(); + $lang1 ||= find { /_$uc_country/ } list(); + $lang2 ||= find { int grep { /^$country/ } split(':', lang2LANGUAGE($_)) } list(); + $lang2 ||= find { int grep { /_$uc_country/ } split(':', lang2LANGUAGE($_)) } list(); ($lang1 =~ /UTF-8/ && $lang2 !~ /UTF-8/ ? $lang2 || $lang1 : $lang1 || $lang2) || $default || 'en_US'; } @@ -466,13 +466,13 @@ sub lang2kde_lang { my $r; $r ||= $valid_lang->(lang2LANG($lang)); - $r ||= first(grep { $valid_lang->($_) } split(':', lang2LANGUAGE($lang))); + $r ||= find { $valid_lang->($_) } split(':', lang2LANGUAGE($lang)); $r || $default || 'C'; } sub kde_lang2lang { my ($klang, $default) = @_; - first(grep { /^$klang/ } list()) || $default || 'en_US'; + (find { /^$klang/ } list()) || $default || 'en_US'; } sub kde_lang_country2lang { @@ -581,8 +581,8 @@ sub set { if ($lang && !exists $languages{$lang}) { #- try to find the best lang - my ($lang2) = grep { /^\Q$lang/ } list(); #- $lang is not precise enough, choose the first complete - my ($lang3) = grep { $lang =~ /^\Q$_/ } list(); #- $lang is too precise, choose the first substring matching + my $lang2 = find { /^\Q$lang/ } list(); #- $lang is not precise enough, choose the first complete + my $lang3 = find { $lang =~ /^\Q$_/ } list(); #- $lang is too precise, choose the first substring matching log::l("lang::set: fixing $lang with ", $lang2 || $lang3); $lang = $lang2 || $lang3; } diff --git a/perl-install/modules.pm b/perl-install/modules.pm index f90d6c895..2b798ddd9 100644 --- a/perl-install/modules.pm +++ b/perl-install/modules.pm @@ -56,7 +56,7 @@ sub load { } else { load_raw(map { [ $_ => $options{$_} ] } @l); } - sleep 2 if grep { /^(usb-storage|mousedev|printer)$/ } @l; + sleep 2 if any { /^(usb-storage|mousedev|printer)$/ } @l; if ($network_module) { add_alias($_, $network_module) foreach difference2([ detect_devices::getNet() ], \@network_devices); @@ -256,7 +256,7 @@ sub write_conf { } my @l; push @l, 'scsi_hostadapter' if !is_empty_array_ref($conf{scsi_hostadapter}{probeall}); - push @l, 'bttv' if grep { $_->{driver} eq 'bttv' } detect_devices::probeall(); + push @l, 'bttv' if any { $_->{driver} eq 'bttv' } detect_devices::probeall(); append_to_etc_modules($prefix, @l); } diff --git a/perl-install/network/drakfirewall.pm b/perl-install/network/drakfirewall.pm index 8951ecd44..084a656fd 100644 --- a/perl-install/network/drakfirewall.pm +++ b/perl-install/network/drakfirewall.pm @@ -54,10 +54,9 @@ my @all_servers = sub port2server { my ($port) = @_; - foreach (@all_servers) { - return $_ if grep { $port eq $_ } split ' ', $_->{ports}; - } - undef; + find { + any { $port eq $_ } split(' ', $_->{ports}); + } @all_servers; } sub check_ports_syntax { @@ -95,7 +94,7 @@ sub default_from_pkgs { my @pkgs = $in->do_pkgs->are_installed(map { split ' ', $_->{pkg} } @all_servers); [ grep { my $s = $_; - grep { member($_, @pkgs) } split ' ', $s->{pkg}; + any { member($_, @pkgs) } (split ' ', $s->{pkg}); } @all_servers ]; } diff --git a/perl-install/network/ethernet.pm b/perl-install/network/ethernet.pm index 69135e363..91eac7d69 100644 --- a/perl-install/network/ethernet.pm +++ b/perl-install/network/ethernet.pm @@ -62,7 +62,7 @@ sub configure_lan { configureNetwork($netc, $intf, $first_time) or return; configureNetwork2($in, $prefix, $netc, $intf); $netc->{NETWORKING} = "yes"; - if ($netc->{GATEWAY} || grep { $_->{BOOTPROTO} eq 'dhcp' } values %$intf) { + if ($netc->{GATEWAY} || any { $_->{BOOTPROTO} eq 'dhcp' } values %$intf) { $netcnx->{type} = 'lan'; $netcnx->{NET_DEVICE} = $netc->{NET_DEVICE} = ''; $netcnx->{NET_INTERFACE} = 'lan'; #$netc->{NET_INTERFACE}; diff --git a/perl-install/network/network.pm b/perl-install/network/network.pm index 888630b3d..bce84c86f 100644 --- a/perl-install/network/network.pm +++ b/perl-install/network/network.pm @@ -203,7 +203,7 @@ my $ip_regexp = qr/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/; sub is_ip { my ($ip) = @_; my @fields = $ip =~ $ip_regexp or return; - return if grep { $_ < 0 || $_ > 255 } @fields; + every { 0 <= $_ && $_ <= 255 } @fields or return; @fields; } sub is_domain_name { @@ -449,10 +449,10 @@ sub configureNetwork2 { write_interface_conf("$etc/sysconfig/network-scripts/ifcfg-$_->{DEVICE}", $_, $prefix) foreach grep { $_->{DEVICE} } values %$intf; add2hosts("$etc/hosts", $netc->{HOSTNAME}, map { $_->{IPADDR} } values %$intf); - if (grep { $_->{BOOTPROTO} =~ /^(dhcp)$/ } values %$intf) { + if (any { $_->{BOOTPROTO} =~ /^(dhcp)$/ } values %$intf) { $in->do_pkgs->install($netc->{dhcp_client} ? $netc->{dhcp_client} : 'dhcpcd'); } - if (grep { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %$intf) { + if (any { $_->{BOOTPROTO} =~ /^(pump|bootp)$/ } values %$intf) { $in->do_pkgs->install('pump'); } #-res_init(); #- reinit the resolver so DNS changes take affect diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm index 7adf01a3a..6215e3150 100644 --- a/perl-install/network/smb.pm +++ b/perl-install/network/smb.pm @@ -70,7 +70,7 @@ sub find_servers { my ($group, $name) = split(' ', lc($_)); # already done - next if grep { $group eq $_->{group} } values %servers; + next if any { $group eq $_->{group} } values %servers; $l{$name} = $group; } diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 39a164575..53e405da6 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -565,7 +565,7 @@ sub write { $_->{local_start} = $_->{start}; $_->{active} ||= 0; } - $l[0]{active} = 0x80 if !grep { $_->{active} } @l; + $l[0]{active} = 0x80 if !any { $_->{active} } @l; } #- last chance for verification, this make sure if an error is detected, diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm index 0f45ec00d..adf370d09 100644 --- a/perl-install/pkgs.pm +++ b/perl-install/pkgs.pm @@ -486,7 +486,7 @@ sub read_rpmsrate { } if ($data) { # has packages on same line - my ($rate) = grep { /^\d$/ } @m or die sprintf qq(missing rate for "%s" at line %d (flags are %s)\n), $data, $line_nb, join('&&', @m); + my $rate = find { /^\d$/ } @m or die sprintf qq(missing rate for "%s" at line %d (flags are %s)\n), $data, $line_nb, join('&&', @m); foreach (split ' ', $data) { if ($packages) { my $p = packageByName($packages, $_) or next; @@ -555,7 +555,7 @@ sub saveCompssUsers { $flat .= $compssUsers->{$_}{verbatim}; foreach my $p (@{$packages->{depslist}}) { my @flags = $p->rflags; - if ($p->rate && grep { grep { !/^!/ && $fl{$_} } split('\|\|') } @flags) { + if ($p->rate && any { any { !/^!/ && $fl{$_} } split('\|\|') } @flags) { $flat .= sprintf "\t%d %s\n", $p->rate, $p->name; } } @@ -571,7 +571,7 @@ sub setSelectedFromCompssList { my @flags = $p->rflags; next if !$p->rate || $p->rate < $min_level || - grep { !grep { /^!(.*)/ ? !$compssUsersChoice->{$1} : $compssUsersChoice->{$_} } split('\|\|') } @flags; + any { !any { /^!(.*)/ ? !$compssUsersChoice->{$1} : $compssUsersChoice->{$_} } split('\|\|') } @flags; #- determine the packages that will be selected when #- selecting $p. the packages are not selected. diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index fe7c03cfa..cbc73d529 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -611,7 +611,7 @@ sub set_cups_special_options { # If nothing is already configured, set text file borders of half an inch # and decrease the font size a little bit, so nothing of the text gets # cut off by unprintable borders. - if (!grep { /$queue.*\s(page-(top|bottom|left|right)|lpi|cpi)=/ } @lpoptions) { + if (!any { /$queue.*\s(page-(top|bottom|left|right)|lpi|cpi)=/ } @lpoptions) { run_program::rooted($::prefix, "lpoptions", "-p", $queue, "-o", "page-top=36", "-o", "page-bottom=36", @@ -619,7 +619,7 @@ sub set_cups_special_options { "-o", "cpi=12", "-o", "lpi=7", "-o", "wrap"); } # Let images fill the whole page by default - if (!grep { /$queue.*\s(scaling|natural-scaling|ppi)=/ } @lpoptions) { + if (!any { /$queue.*\s(scaling|natural-scaling|ppi)=/ } @lpoptions) { run_program::rooted($::prefix, "lpoptions", "-p", $queue, "-o", "scaling=100"); diff --git a/perl-install/printer/printerdrake.pm b/perl-install/printer/printerdrake.pm index 55e44ffed..f15b9d03e 100644 --- a/perl-install/printer/printerdrake.pm +++ b/perl-install/printer/printerdrake.pm @@ -2882,9 +2882,7 @@ sub main { $cursorpos = $printer->{configured}{$printer->{DEFAULT}}{queuedata}{menuentry} . N(" (Default)"); } elsif ($printer->{SPOOLER} eq "cups") { - ($cursorpos) = - grep { /!$printer->{DEFAULT}:[^!]*$/ } - printer::cups::get_formatted_remote_queues($printer); + $cursorpos = find { /!$printer->{DEFAULT}:[^!]*$/ } printer::cups::get_formatted_remote_queues($printer); } } # Generate the list of available printers diff --git a/perl-install/raid.pm b/perl-install/raid.pm index 3f4488ad8..ab6fa0fcb 100644 --- a/perl-install/raid.pm +++ b/perl-install/raid.pm @@ -174,7 +174,7 @@ sub inactivate_and_dirty { sub is_active { my ($dev) = @_; - grep { /^$dev / } cat_("/proc/mdstat"); + cat_("/proc/mdstat") =~ /^$dev /m; } sub inactivate_all() { run_program::run("raidstop", devices::make("md$_")) foreach 0..7 } diff --git a/perl-install/standalone/drakfont b/perl-install/standalone/drakfont index 9449bc97d..959b4b055 100755 --- a/perl-install/standalone/drakfont +++ b/perl-install/standalone/drakfont @@ -243,7 +243,7 @@ sub search_windows_font { return 0; } } - !$replace && grep(/$i/, @installed_fonts) and next; + !$replace && any { /$i/ } @installed_fonts and next; grep (/$i$/, @font_list) or push @font_list, "$win_dir/$_->[1]/fonts/$i"; } @@ -285,8 +285,7 @@ sub search_dir_font { if (is_a_font($i)) { push @font_list_tmp, "$i"; foreach my $i (@font_list_tmp) { - !$replace && grep(/$i/, @installed_fonts) - and next; + !$replace && any { /$i/ } @installed_fonts and next; grep /$i/, @font_list or push @font_list, "$fn/$i"; } } @@ -294,7 +293,7 @@ sub search_dir_font { } else { if (is_a_font($fn)) { - !$replace && grep(/$fn/, @installed_fonts) and next; + !$replace && any { /$fn/ } @installed_fonts and next; !grep /$fn/, (@installed_fonts) and push @font_list, "$fn"; } } diff --git a/perl-install/timezone.pm b/perl-install/timezone.pm index 6a3d86f99..e82d6cca5 100644 --- a/perl-install/timezone.pm +++ b/perl-install/timezone.pm @@ -36,7 +36,7 @@ sub ntp_server { } $f; output("$prefix/etc/ntp/step-tickers", "$server\n"); } else { - ($server) = grep { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($f); + $server = find { $_ ne '127.127.1.0' } map { if_(/^\s*server\s+(\S*)/, $1) } cat_($f); } $server; } |