Here i am explaining in detail what actually i am trying to extract.

And you seem to be completely ignoring (or not understanding) the code sample and suggestions that I posted. If you don't understand something I've said or something in my code, it's okay to quote me in a reply and say that you don't understand.

i am matching the output for the tags with 2 slashes in it ex:/vobs/cs_test_script and vobtag with one slash in it ex:/scm with regular expression that has to match the output for both type of vobtags(/vobs/cs_test_script,/scm)by using alternation operator in pattern matching as below script

Checking your code, I have learned something. I expected that if a regex that starts like this:  /^*\s+/ it would be a syntax error, and the script would not run at all. But having tried it, I see that it does run (it's not an error), and it even seems to work: $_="* foo"; m{^*\s+foo} returns true.

Still, I prefer using a backslash when I want to match a literal "*" character. Note that  m{*\s+foo} is a syntax error.

(And make sure you understand the distinction: slash is "/", backslash is "\", and the two have very different meanings and uses in perl.)

i am combining the pattern match of storage1 and storage2 by alternation operator

You don't need to use an alternation (|) in the regex. The code that I suggested above uses a quantifier, so that one, two, three or more slashes in the path string can be treated by the single expression -- shown here with commentary:

m{^ # at the start of the string \* # match a literal asterisk character \s+ # then one or more whitespace characters (?: # begin a non-capturing group expression / # match a literal slash character \w+ # then one or more alphanumeric_word characters )+ # close the group, match 1 or more instances of that expr +ession \s+ # then one or more whitespace characters (\S+) # capture a group of non-whitespace characters }x # end of regex (x modifier lets comments and spacing be i +gnored)

The last couple things that you are not paying attention to are: whether you need to be processing your data line by line, rather than slurping all the lines into a single "$arr" variable, and whether you would be better off using "split" instead of regex matches.


In reply to Re^5: Problem in pattern matching with alternation by graff
in thread Problem in pattern matching with alternation by perladdict

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.