Tip: my keeper example of qqx and match

[email protected] (ToddAndMargo via perl6-users)
Newsgroups perl.perl6.users
Message-ID <[email protected]>
Hi All,

I wrote myself a nice example of how to use `qqx`
and `m:` (match).   It is pretty simple, so it
is probably "way under" the heads of most of you.
But it is a nice example for beginners:


Notes:
    resplendence.com is the home of "Who Crashed":
    a great utility for Windows users.

    the example requires `curl` to be installed.

    tests of the example were run under Fedora
    Linux V 37.  Windows was not tested.


<RegexTest2>
#!/bin/raku

my Str $WebSite = "https://www.resplendence.com/main";
my Str $Match   = "";

$WebSite = qqx { curl -L "$WebSite" -o - };
print "\n";

#`{ $WebSite line 913 to 916 (as of 2023-06-23)

     <p><font face="Open Sans, Arial" size="2">
     WhoCrashed has been updated to v 7.06.
     To see what's changed <a href="/whocrashed_whatsnew"; font-weight: 
bold"><b>click here</b></a>.
     </font></p>
}

if not  $WebSite~~m:i/ .*? ( "WhoCrashed has been updated to v ")  (.*?) 
(".") (.*?) "." / {
    print "The match failed.  Cowardly Exiting.  Bummer Dude!\n";
    exit;
}

print "\$0 = <" ~ $0 ~ ">\n";
print "\$1 = <" ~ $1 ~ ">\n";
print "\$2 = <" ~ $2 ~ ">\n";
print "\$3 = <" ~ $3 ~ ">\n\n";

$Match = $1 ~ $2 ~ $3;
print "Version (Match) = <" ~ $Match ~ ">\n";
print "Expected output = <7.06>  until the next update\n\n";
/<RegexTest2>


Result:

$ RegexTest2.pl6
   % Total    % Received % Xferd  Average Speed   Time    Time     Time 
Current
                                  Dload  Upload   Total   Spent    Left 
Speed
100 74882  100 74882    0     0   225k      0 --:--:-- --:--:-- --:--:-- 
  225k

$0 = <WhoCrashed has been updated to v >
$1 = <7>
$2 = <.>
$3 = <06>

Version (Match) = <7.06>
Expected output = <7.06>  until the next update


-T
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.