Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Multiline match

by hdb (Parson)
on May 23, 2013 at 16:22 UTC ( #1034975=note: print w/ replies, xml ) Need Help??


in reply to Multiline match

Whatever you are trying: "patch-5.1.1.21510.gpg" will not match to your $output because of the ".gpg" extension...


Comment on Re: Multiline match
Re^2: Multiline match
by arunbhargav (Novice) on May 23, 2013 at 16:27 UTC
    patch-5.1.1.21510 is a substring of patch-5.1.1.21510.gpg, hence it should match. All it wants to match is patch-5.1.1.21510, it doesnt care about gpg
      But your explanation was the other way round.

      plz try to show us a reproducible code example instead of wording.

      Cheers Rolf

      ( addicted to the Perl Programming Language)

        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"; }

      hdb's point was your code boils down to 'patch-5.1.1.21510' =~ /patch-5.1.1.21510.gpg/;, which is backwards from what you need. The behavior you seek would look more like

      my @array = split('\n',$output); if ( grep { 'patch-5.1.1.21510.gpg' =~ /\Q$_\E/ } @array ) { print "Match found\n"; }
      Though, as implemented, you'd have problems because of whitespace. For this case, you'd probably be better off using index.

      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        Exactly!



Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1034975]
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: (8)
As of 2014-07-14 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (255 votes), past polls