#!/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 ); while ( <$PIPE> ) { $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'"; print "$i applications, $p PowerPC applications\n\n";