chicken: (27. Braaaains!)
[personal profile] chicken
Question for the geeks.

I'm trying to find a Perl way of doing PHP's in_array.

I feel very stupid right now. Help!

(no subject)

Date: 2005-08-11 08:49 pm (UTC)
From: [identity profile] paulv.livejournal.com
Well, there's also this question in perlfaq4. It's probably right about using a hash instead of an array.

(no subject)

Date: 2005-08-11 09:14 pm (UTC)
From: [identity profile] chicken-cem.livejournal.com
Yes, a hash really is better in this case. Funny I didn't think of it because I've used three other hashes in this program so far. Grr. Argh!

BTW, major points for making your example use Whedonverse content. Shouldn't all programming examples work this way? ;-)

sub buffyBotSubRoutine_boolean001 {
  # Are we allowed to pass a whole
  #  array as a param?
  my @nest = shift;
  my $wanted = "Spike";;
  foreach my $vampire (@nest) {
    if ($vampire eq $wanted) {
      buffyBotSubRoutine_shagHim($vampire);
    } else {
      buffyBotSubRoutine_stakeHim($vampire);
    }
  }
}

Profile

chicken: (Default)
chicken

April 2009

S M T W T F S
   1234
56 78 9 1011
12131415161718
192021 22232425
2627282930  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags