in reply to Pulling data out of { }

Here's one way (untested tested):

use strict; use warnings; use Data::Dumper; my %disks; { local $/ = "};"; while( my $record = <DATA> ) { chomp $record; my %attribs; foreach my $line ( split /\n/, $record ) { next unless $line =~ m/=.+;/; chomp $line; $line =~ s/^\s+//; $line =~ s/\s*;\s*$//; my( $key, $value ) = split /\s*=\s*/, $line; $value =~ s/"//g; $attribs{$key} = $value; } next if not exists $attribs{'Name'}; # Just in case. ;) $disks{ $attribs{ 'Name' } } = { %attribs }; } } print Dumper \%disks; __DATA__ instance of Win32_LogicalDisk { FreeSpace = "114151464960"; Name = "C:"; Size = "160031014912"; }; instance of Win32_LogicalDisk { FreeSpace = "5515554816"; Name = "D:"; Size = "203921108992"; }; instance of Win32_LogicalDisk { FreeSpace = "43128733696"; Name = "H:"; Size = "400086708224"; };

Updated: Tweaked code to provide HoH rather than AoH.


Dave