Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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 Tk.pm 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. ...at 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 +seMatcher_PM_Script.pl line 88. #syntax error at KJV_VerseMatcher_PM_Script.pl line 89, near "})"

Blessings,

~Polyglot~

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[...] });

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

    Update:

    ... 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.

      Blessings,

      ~Polyglot~

        See pragma.


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2021-09-24 10:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?