Search notes:

Perl operator: ~~ (tilde tilde)

A.k.a smart matching
#!/usr/bin/perl

use warnings;
use strict;

my @items = qw(foo bar baz);

is_in_items('bar');
is_in_items('strawberry');

sub is_in_items {
  my $item = shift;

  if ($item ~~ @items) {
    print "$item is in \@items\n";
  }
  else {
    print "$item is in not \@items\n";
  }
}
# 
# Smartmatch is experimental at ./~~.pl line 14.
# bar is in @items
# strawberry is in not @items
Github repository about-perl, path: /operators/~~.pl

See also

Perl operators

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759428692, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/Perl/operators/tilde_tilde(64): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78