Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: String Comparison & Equivalence Challenge

by Polyglot (Friar)
on Mar 15, 2021 at 04:06 UTC ( #11129642=note: print w/replies, xml ) Need Help??

in reply to Re: String Comparison & Equivalence Challenge
in thread String Comparison & Equivalence Challenge

I took several minutes to install so that I could run this. I was really curious what it actually accomplished in just 2.6 seconds--or if, perhaps, it would be much different on my computer. Alas, I have perl 5.12, which is not compatible with the s///r pragma. I tried a couple of things to work around that, but feel like I'm working in the dark here, never having entirely grasped map or what it does. the risk of appearing foolish, here's what I tried for that line that didn't work.

$ro->insert(end => join "", map { do { (my $s = $_ ) =~ s/^(\d\d)\d* +/$1%/ . "\n"; $s }, @matches[0 .. $bestcount - 1] }); #RESULT: #Useless use of concatenation (.) or string in void context at KJV_Ver line 88. #syntax error at line 89, near "})"



Replies are listed 'Best First'.
Re^3: String Comparison & Equivalence Challenge
by AnomalousMonk (Bishop) on Mar 15, 2021 at 04:28 UTC
    $ro->insert(end => join "", map s/^(\d\d)\d*/$1%/r . "\n", @matches[...] );
    $ro->insert(end => join "", map { do { (my $s = $_ ) =~ s/^(\d\d)\d*/$1%/ . "\n"; $s }, @matches[...] });

        $ro->insert(end => join "", map { (my $r = $_) =~ s/^(\d\d)\d*/$1%/;  "$r\n"; } @matches[0 .. $bestcount - 1]);


    ... the s///r pragma.
    NB: s///r is not a pragma. /r is a modifier (update: available from Perl version 5.14 on) of the s/// operator.

    Give a man a fish:  <%-{-{-{-<

      Thank you very much! The script works with that adjustment. BTW, "pragma" is not even in my dictionary--so I'm not able to easily verify its usage. I guess I'm a bit vocabulary challenged today.



        See pragma.

        Give a man a fish:  <%-{-{-{-<

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129642]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2022-01-17 17:27 GMT
Find Nodes?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:

    Results (51 votes). Check out past polls.