This is a really simple demo of a real-world way to use Quantum::Superpositions. I use this to filter out a lot of the noise from my pf firewall logs and figured I'd share since I think that more people need to understand how useful the any() operator is. You'll get this right in the core of perl6.

Added: fixed qw(). I seem to have mistaken it with the regex flag /x.

use strict; use Quantum::Superpositions; our ($r, $ignore_src_ip, $ignore_src_prt, $ignore_dst_prt); INIT { my $r_date = "\\w+\\s+\\d+"; my $r_time = "[\\d:.]+"; my $r_ip = "\\d+\\.\\d+\\.\\d+\\.\\d+"; my $r_port = "\\d+"; my $r_dir = "[<>]"; my $r_text = ".+"; $r = qr[^($r_date)\s+($r_time)\s+($r_ip)\.($r_port)\s+($r_dir)\s+( +?:($r_ip)\.)?($r_port):\s+($r_text)]; $ignore_src_ip = any(qw[ 198.144.10.227 163.228.80.5 198.144.10.143 ]); $ignore_src_prt = 53; $ignore_dst_prt = any( 137, # NETBIOS Name Service 139, # NETBIOS Session Service 445, # Win2k+ Server Message Block 1434, # SQL Slammer / Sapphire worm ); } my ($date, $time, $src_ip, $src_prt, $dir, $dst_ip, $dst_prt, $text) = + /$r/; next if $src_ip eq $ignore_src_ip or $src_prt == $ignore_src_prt or $dst_prt == $ignore_dst_prt; print; __END__ May 17 20:38:18.469635 64.180.225.226.1025 > 137: udp 50 May 17 21:07:01.043863 202.108.249.21.1122 > 1434: udp 376 May 17 21:38:22.550924 210.14.199.234.4110 > 445: S 318758155:31875815 +5(0) win 16384 <mss 1460,nop,nop,sackOK> (DF) May 17 21:38:54.775616 216.219.104.135.1236 > 1434: udp 376 May 17 21:51:00.660588 63.203.70.246.1028 > 137: udp 50 May 17 22:04:31.767281 218.187.142.250.1029 > 137: udp 50

In reply to tcpdump filter (sample use of Quantum::Superpositions) by diotalevi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.