I run a command which has the following results from STDOUT:
Serial=102345
Name=Server1
Type=Windows
....
Serial=345069
Name=Server2
Type=Linux
...
etc
How do I place each combo of serial and type into a hash for easy reference
The idea is to get a hash like so
102345 => Windows
345069 =>Linux
etc
File should look like:
102345=Windows
345069=Linux
etc
Serial=102345
Name=Server1
Type=Windows
....
Serial=345069
Name=Server2
Type=Linux
...
etc
How do I place each combo of serial and type into a hash for easy reference
Code:
my %hash;
my @cmd = `command`;
foreach $line(@cmd) {
if ($line1 =~ /^Server=(\d{6})) {
if ($line2=~ /^Type=(\w+)) {
#enter $line1 and $line2 values into hash
# I know this is wrong
$hash($1)= $2;
#write results out to file
}
}
}
The idea is to get a hash like so
102345 => Windows
345069 =>Linux
etc
File should look like:
102345=Windows
345069=Linux
etc