in reply to Grepping a File

well, grep operates on a list, so you'd better apply it to the lines directly. Instead of slurping the file into a scalar buffer, why not put it in an array in the first place?
use strict; use warnings; open my $fh, '<', 'defines.h' or die $!; my @lines = <$fh>; my @all_28s = grep /28/, @lines; my @all_42s = grep /UNIVERSE_ANSWER/, @lines;