use warnings; use strict; while (<>) { chomp; if (m/(.+?)\s+?=\s+?(\d+?).?$/) { print $1, " : ", $2, $/; } } #### #!/usr/bin/perl use warnings; use strict; open my $fh,'-|', q[xgridstatus -h localhost -A] or die "can open this file: $!"; while (<$fh>) { chomp; if (m/(.+?)\s+?=\s+?(\d+?).?$/) { print $1, " : ", $2, $/; } } close $fh or die "can't close this file:$!";