Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Grep asterisk sign in input file

by Athanasius (Archbishop)
on Jul 25, 2017 at 07:18 UTC ( [id://1195951]=note: print w/replies, xml ) Need Help??


in reply to Re: Grep asterisk sign in input file
in thread Grep asterisk sign in input file

Hello choroba,

Nice solution, especially the inclusion of last which avoids a potentially nasty bug.

But as it stands, this code will match a filter value such as ac* with an input value such as zac1234 — which doesn’t appear to be what the OP wants. This is easily fixed by anchoring the filter regex to the beginning of the match:

$value = $filter->[1], last if $key =~ /^$filter->[0]/;

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-29 10:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found