Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: no way it's not a bug of Perl

by ikegami (Patriarch)
on Jul 14, 2024 at 13:17 UTC ( [id://11160600]=note: print w/replies, xml ) Need Help??


in reply to Re^4: no way it's not a bug of Perl
in thread I thought I found a bug of Perl

s/(?:)// will do nothing (or rather, replace one-zero length string with another zero-length string). So, if you have a possibly-empty pattern in a variable, you could use

s/(?:$pat)//

or

my $re = qr/$pat/; s/$re//

The latter was buggy before 5.18 as it resulted in the same as s/// when $pat contained an empty string.

Replies are listed 'Best First'.
Re^6: no way it's not a bug of Perl
by vincentaxhe (Beadle) on Jul 14, 2024 at 14:02 UTC
    glad to learn that there is a way to suppress the urge of abnormal behavior.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-09-11 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (13 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.