Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Checking a string's presence within an array.

by antirice (Priest)
on May 16, 2003 at 17:56 UTC ( [id://258712]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @array_I_just_created_here = (a .. z);
    
    my @hash_I_just_created_here{@array_I_just_created_here} = ();
    print "yes, c is a letter that would exist within that array you just 
    +created there.$/" if exists $hash_I_just_created_here{"c"};
    
  2. or download this
    my $found = 0;
    my @array_I_just_created_here = (a .. z);
    
    $found |= ("c" eq $array_I_just_created_here[$_]) foreach (0..$#array_
    +I_just_created_here);
    print "yes, c is a letter that would exist within that array you just 
    +created there.$/" if $found;
    
  3. or download this
    my $find_item = "c";
    my @array_I_just_created_here = (a .. z);
    ...
        return bin_search($array, $val, $pos, $max);
      }
    }
    
  4. or download this
    print "yes, c is a letter that would exist within that array you hadn'
    +t created there.$/" if "c" =~ m/^(?:a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q
    +|r|s|t|u|v|w|x|y|z)$/;
    
  5. or download this
    use Quantum::Superpositions;
    
    my @array_I_just_created_here = (a .. z);
    
    print "yes, c is a letter that would exist within that array you just 
    +created there.$/" if ("c" eq any(@array_I_just_created_here);
    

Log In?
Username:
Password:

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

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

    No recent polls found