Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Best approach to creating a regex from a filehandle

by smls (Friar)
on May 18, 2014 at 20:26 UTC ( [id://1086547]=note: print w/replies, xml ) Need Help??


in reply to Re: Best approach to creating a regex from a filehandle
in thread Best approach to creating a regex from a filehandle

Unless you're sure that the input file will only contain safe characters, you should call quotemeta on $_ inside the map.
Also, what's the benefit of chaining two map's like that, instead of combining them into one?

Edit: Oops, I only just now noticed that choroba already mentioned quotemeta in his answer. Sorry for the redundancy.

Replies are listed 'Best First'.
Re^3: Best approach to creating a regex from a filehandle
by toolic (Bishop) on May 18, 2014 at 22:15 UTC
    You're right... it can be simplified using a single map
    my $blacklist_regex = join "|" => map { chomp; "(?:$_)"} <BLIST>;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1086547]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2024-04-23 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found