#!/usr/bin/perl use strict; use warnings; my $re = qr{ (?&opengamediv) (?# opening div contating start of data ) id="(?\d+)-game" (?# gameid --> id='12345-game' -> 12345 ) (?.*?) (?# Skip a lot of content non-greedily ) (?&comment_open) (?# open comment contatining status ) (?\d+) (?# gamestatus=12344 -> 12344 ) (?&comment_close) (?# closing comment to make sure we get all digits ) (?# Rules ) (?(DEFINE) (? )(?# overkill ) )}xsim; my @d = (); my $s = <<'EOF';
hello world fooo bar
EOF if ( $s =~ $re ) { print "The Expression matched, resulting variables were discovered. : \n"; for my $key ( keys %+ ) { printf "\t%s: %s\n", $key, $+{$key}; } print "Used Expression: \n", $re, "\n"; } else { print "The Content Did not match the expression: \n", $re, "\n"; }