Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: delete multiple string blocks

by grandagent (Novice)
on Aug 08, 2019 at 11:21 UTC ( [id://11104157]=note: print w/replies, xml ) Need Help??


in reply to Re: delete multiple string blocks
in thread delete multiple string blocks

Thanks a lot that worked! Could you elaborate a bit on how this works in detail? Would appreciate that mate..

Replies are listed 'Best First'.
Re^3: delete multiple string blocks
by hippo (Bishop) on Aug 08, 2019 at 13:13 UTC

    Sure. Working from the inside out:

    1. index looks for the substring within the string. Any result greater than -1 indicates it has been found. (If you know your substrings are always at the beginning of the string you can check for zero here)
    2. grep attempts the block of code against every element of the supplied array and returns those which evaluate to a true value.
    3. if tests all this for truth, ie. if the list returned by grep has elements.

    Note that grep isn't the most efficient here because it will go on testing even after a match is found. For a short array/list it won't matter much. For a longer array/list you might want List::Util::any instead.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-19 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found