#! perl -slw use strict; $/ = 'Drive'; while( ) { print "$1 : $2" if m[(Tray .*?)\nRaw capacity: (.*?)\n.*Unassigned]s; } __DATA__ Drive at Tray 0, Slot 1 Raw capacity: 68.366 GB Usable capacity: 67.866 GB Current data rate: 2 Gbps Product ID: ST373453FC Mode: Assigned Drive at Tray 0, Slot 2 Raw capacity: 68.366 GB Usable capacity: 67.866 GB Current data rate: 2 Gbps Product ID: ST373453FC Mode: Unassigned Drive at Tray 0, Slot 3 Raw capacity: 68.366 GB Usable capacity: 67.866 GB Current data rate: 2 Gbps Product ID: ST373453FC Mode: Assigned Drive at Tray 0, Slot 4 Raw capacity: 68.366 GB Usable capacity: 67.866 GB Current data rate: 2 Gbps Product ID: ST373453FC Mode: Unassigned Drive at Tray 0, Slot 5 Raw capacity: 68.366 GB Usable capacity: 67.866 GB Current data rate: 2 Gbps Product ID: ST373453FC Mode: Assigned