#!/usr/bin/perl use warnings; use strict; open my $PIPE, '-|', 'system_profiler SPApplicationsDataType 2> /dev/null' or die "Cannot open pipe from 'system_profiler' $!"; my ( $i, $p, @apps ); while ( <$PIPE> ) { $apps[$i] .= $_; $i += /\A\s{4}\S.*:\Z/; $p += /\A\s+Kind: PowerPC\Z/; } close $PIPE or warn $! ? "Error closing 'system_profiler' pipe: $!" : "Exit status $? from 'system_profiler'"; foreach (@apps) { print if /Kind: PowerPC/s; } print "$i applications, $p PowerPC applications\n\n";