Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Smartmatch alternatives

by BrowserUk (Pope)
on Dec 17, 2013 at 13:10 UTC ( #1067466=note: print w/replies, xml ) Need Help??

in reply to Smartmatch alternatives

Can['t] use the exists() function either, because it's use on arrays is deprecated as well.

It wouldn't help any way. exists on an array only tests if the array element at a given index exists (ie. has not been deleted), and has nothing to do with what it contains.

Is there a proper, future-proof alternative that does not require me to sprinkle foreach test loops all over the place?

Like this:

if( grep /^\Q$scalar$/, @array ) { ## it's in there }

Of course, that uses the implicit $_; so perhaps you'd prefer:

if( grep $_ eq $scalar, @array ) { ## it's in there }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1067466]
[MidLifeXis]: Weird - my team is receiving a request for information barely related to a project we are on, asking for information already available to the user from a corporate data source, which happens to be the same source we would use.
[MidLifeXis]: It seems like the requester believes that we have some magic 8 ball source of info that he doesn't have access to.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2017-01-20 18:51 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (176 votes). Check out past polls.