($UUID) = map { (split (/"/, $_))[-1] } grep { /IOPlatformUUID/ } `ioreg -d2 -c IOPlatformExpertDevice`; print $UUID; #### #!/usr/bin/env perl use strict; use warnings; my ($UUID) = map { (split (/"/, $_))[-1] } grep { /IOPlatformUUID/ } 'IOPlatformUUID = "foo"'; print "$UUID\n";