in reply to grep equivalent in perl

In your first example, you grep all of your "large" files, and then use only the first result. How many large files are you opening unnecessarily?

How does this compare:

my $hba_alias = `for f in $switchdir/*.swc ; do grep $host_hi \$f & +& break; done |grep ": device-alias"`;

That's analogous to graff's last if $hba_alias;