Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: boolean IN(); function in perl like

by mlh2003 (Scribe)
on Jan 18, 2005 at 07:24 UTC ( #422916=note: print w/replies, xml ) Need Help??


in reply to boolean IN(); function in perl like

Not sure, but what about a combination of join and index? I understand that both these functions are quite fast... Something like:
sub s_in_a { my $s = shift; my $joined = '#' . join('#', @_) . '#'; if (index($joined, "#$s#") >= 0) { return 1; } else { return 0; } }

Replies are listed 'Best First'.
Re^2: boolean IN(); function in perl like
by gaal (Parson) on Jan 18, 2005 at 11:37 UTC
    You then have to be picky about a delimiter. If the data has #s in it, this breaks.
      Yes, that's correct. You'd have to know in advance what characters are used in the data set before choosing a delimiter. Sometimes it is known, sometimes not.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2021-10-25 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?