in reply to Re: Large File Parsing
in thread Large File Parsing

my $rxMatchItems = do { local $" = q{|}; qr{(?:@items)} };

Oh noes :)

my $rxMatchItems = join '|', map quotemeta, @items; $rxMatchItems = qr/$rxMatchItems/;

Replies are listed 'Best First'.
Re^3: Large File Parsing
by johngg (Canon) on Jan 03, 2010 at 11:19 UTC

    I'm guessing from the variable name and the use of quoting constructs that the OP grabbed that bit of code from one of my solutions, probably one where @items contained values known not to need quotemeta'ing. Invariable application of quotemeta without any consideration of whether it is necessary is just another form of cargo cult programming. I don't think we can tell from the OP's code whether it is required or not. Even if it is required, the do block construct is as valid as using join.

    my $rxMatchItems = do { local $" = q{|}; qr{(?:@{ [ map quotemeta, @items ] })}; };

    Cheers,

    JohnGG