#!perl -w use strict; my %hash; for () { if ( /\((.+)\), status: (.+)$/ ) { $hash{$1}=$2; } } use Data::Dumper; print Dumper \%hash; __DATA__ ANR8330I LTO volume 000165L1 is mounted R/O in drive MT1.0.0.3 (mt1.0.0.3), status: IN USE. ANR8330I LTO volume 000290L1 is mounted R/W in drive MT1.0.0.2 (mt1.0.0.2), status: IN USE. ANR8329I LTO volume 000114L1 is mounted R/W in drive MT0.0.0.2 (mt0.0.0.2), status: IDLE.