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

Re: Question about regex.

by NetWallah (Canon)
on Sep 29, 2020 at 02:45 UTC ( #11122314=note: print w/replies, xml ) Need Help??


in reply to Question about regex.

A little line shuffling and error checking fixes this:
use strict; use warnings; open (my $fh, "<", "testlines.txt") or die "$!"; local $/ = "\n\n"; while (<$fh>) { if ($_=~ /(third | four)/si) { chomp; print "line is: $_\n"; } } close $fh;
Code>perl test15.pl line is: This is line one. Line Two is this. Third line starts here. This is line four.

                "Imaginary friends are a sign of a mental disorder if they cause distress, including antisocial behavior. Religion frequently meets that description"

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2021-06-23 04:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (114 votes). Check out past polls.

    Notices?