:How can I grep for each record in array of text filter against postscript
:files?
:ArrayF
:aaaa
:bbbb
:abcd
:ABcd
:I needs to run each record against postscript file and see if there is any
:filter matches?
Tricky. Postscript is a complete programming language in itself.
There is no possible [finite] general mechanism to determine whether
arbitrary Postscript programs wil produce particular outputs.
Consider for example that a Postscript driver might choose to use
absolute positioning to place the AB and then relative positioning
for the following cd. Absolute positioning of an uppercase letter
introducing a word happens quite a bit in Postscript drivers, in
my experience.
What happens if the driver choses to define producing cd as a function,
/frotz1733 (cd) def
[.... thousands of lines of postscript here]
(AB) 12 timesnewroman
frotz1733
?
If you know that the target might appear *as code* then you just
have a traditional matching problem
use strict;
use warnings;
my @ArrayF = qw(aaaa bbbb abcd ABcd);
my $matchstring = join '|', @ArrayF;
print grep { m/$matchstring/o } (<>)
Note 1: as @ArrayF gets big, the backtracking involved in the matching
can really slow you down.
Note 2: Watch out for metacharacters in @ArrayF
Note 3: Your target list suggests you'd be better off doing a case-
insensitive search such as m/aaaa|bbbb|abcd/i .