Hey, I had totally forgotten this; sorry about that.

Yeah, your code is nice, but I really want something small instead of what is basically an entire script(-file). Then again I don't really want to be the person to decide this, so perhaps you could prepare a git patch and just let Thomas know and he'll see.

Good night
Kerim

On 29/08/14 14:28, Thomas Neumann wrote:
Hello Kerim

Can you please explain the following line from Commands.pm?
   my $tmp_vg = `pvdisplay $raid | grep "VG Name" | grep -o "vg[0-9]"`;

Does this really mean you only consider volume groups with a name of
'vg<digit>....' as valid values for $tmp_vg?


This is how I would do it. Maybe there is something I'm missing.

#!/usr/bin/perl

use strict;
use warnings;

my $raid = shift;

# ------------------- the code -------------------------
# fetch the pvdisplay output
my @output = `pvdisplay $raid`;
chomp @output;

# iterate output, looking for volume group name
my $tmp_vg;
for my $line (@output) {
   if ($line =~ /\A \s+ VG[ ]Name \s+ (.+) \z/xms) {
     # found a matching line - extract vg name
     $tmp_vg = $1;
   }
}

defined $tmp_vg
   or croak("Unable to determine volume group for '$raid'");
# ------------------- the code -------------------------

print "$raid -> $tmp_vg\n";



bye
thomas

Reply via email to