in reply to best way to use grep
Crossposted on Stackoverflow. It's polite to mention other places on the web where you asked the same question so that work doesn't get doubled.
Some notes on your post:
$x=grep /$xrefvalue/, @xreflines;
Instead of searching through the @xreflines like that, use instead a hash as the datastructure:
my %xreflines = map { $_ => 1 } grep /\S/, <XREF>; ... $x = $xreflines{ $xrefvalue };
This removes the loop and changes it into a direct lookup whether the xref exists.
Also, for reading a (comma, or semicolon-)delimited file, consider using Text::CSV_XS instead of splitting the data yourself.
|
|---|