#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $raidtab = "./raidtab.txt"; my %info; { my $mnt; local $/ = "\n\n"; open(my $fh,"<",$raidtab) or die $!; while(my $entry = <$fh>){ my ($device,@infos) = split(/\r?\n/,$entry); print $device; ($device) = $device =~ m~(/dev/.*?)$~; chomp(@infos); for my $detail(@infos){ my (undef,$key,$value) = split(/\s+/,$detail); if($key eq 'device'){ $mnt = $value; } elsif($key eq 'raid-disk'){ $info{$device}->{devices}->{$mnt} = $value; } else{ $info{$device}->{$key} = $value; } } } close $fh; }