Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Regex match on implicit default variable ($_) in a script, not a one liner

by mr_ron (Chaplain)
on Oct 24, 2015 at 17:20 UTC ( [id://1145853]=note: print w/replies, xml ) Need Help??


in reply to Regex match on implicit default variable ($_) in a script, not a one liner

I came up with something that seems to match your pipe/one liner closely. It doesn't chomp but you don't match against the end of line so I don't think that matters much.

use strict; use warnings; my $A="abc\ndef\nghi\n"; # remember matching is greedy but # without /s modifier '.' does not match \n my $B = join('', grep { ! /def/ } $A =~ /(.*\n)/g); print $B;
Ron
  • Comment on Re: Regex match on implicit default variable ($_) in a script, not a one liner
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-25 11:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found