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

Re^4: Multiline match

by arunbhargav (Novice)
on May 23, 2013 at 16:33 UTC ( #1034979=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Multiline match
in thread Multiline match

Sorry about the confusion, the following is the code I have been trying

my $str = "update patch-5.1.1.21510"; my $patch = "patch-5.1.1.21510.gpg"; if ($str =~/$patch/ms) { print "Yes \n"; }


Comment on Re^4: Multiline match
Download Code
Re^5: Multiline match
by hdb (Prior) on May 23, 2013 at 16:36 UTC

    Along the lines of your initial code:

    use strict; use warnings; my $PatchPath = "patch-5.1.1.21510.gpg"; my $output = "update patch-5.1.1.21510"; my @array = split /\s+/, $output; if ( grep { $PatchPath =~ /$_/ } @array ) { print "Match found\n"; }

    SORRY: This post is somehow to far up in the chain. Should be a few posts further down...

Re^5: Multiline match
by LanX (Canon) on May 23, 2013 at 16:45 UTC
    thats the way it works

    DB<105> $str = "update\npatch-5.1.1.21510.pgp"; => "update\npatch-5.1.1.21510.pgp" DB<106> $patch = "patch-5.1.1.21510" => "patch-5.1.1.21510" DB<107> $str =~/\Q$patch/ => 1

    $patch must be included in $str not vice versa.

    No need for multiline because your pattern doesn't span multiple lines.

    '\Q' assures that regex syntax like '.' is escaped.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (2)
As of 2014-09-18 03:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (105 votes), past polls