in reply to Is this the best regex?
Perhaps this will work better for you:
#!/usr/bin/perl use warnings; use strict; open my $PIPE, '-|', 'system_profiler SPApplicationsDataType 2> /dev/n +ull' 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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is this the best regex?
by Anonymous Monk on Sep 09, 2009 at 04:51 UTC |