First of all, "/" is slash, "\" is backslash. Having two slashes in path (for Unix like) means that the path has two parts. Saying "2 '\\'" means (at least to me) there are two pairs of adjacent '\', that is "\\" and "\\" :-)

OK, back to the problem...
I tend to think that you want the last part of the path which you can use basename functionality. So,

while (<DATA>) { chomp; (my $tag = (split)[0]) =~ s!.*(/.*)\.vbs$!$1!; print $tag, "\n"; } __DATA__ /usr/add-on/puccase_vob01/ccvob01/bt_rel.vbs public /usr/add-on/puccase_vob01/ccvob01/scm.vbs /usr/add-on/puccase_vob01/ccvob01/v_dialerclient_rel.vbs
would result in
/bt_rel /scm /v_dialerclient_rel
But, I'm confused with /vobs/bt_rel. Where the /vobs part comes from?

Update: The problem with your code is that you are trying to track the path level manually, and using regex complicates the situation.

Update2: I just noticed that the leading asterisks are part of the lines, followed by some space(s) then the tags. Here is my modified code:

$ cat extract-vobtags.pl while (<DATA>) { chomp; my($tag, $storage) = (split)[1,2]; printf "%20s: %s\n", $tag, $storage; } __DATA__ * /vobs/bt_rel /usr/add-on/puccase_vob01/ccvob01/bt_rel.vbs public (re +plicated) * /scm /usr/add-on/puccase_vob01/ccvob01/scm.vbs public (replicated) * /v_dialermidtier /usr/addon/puccase_vob01/ccvob01/v_dialermidtier.vb +s public (replicated) * /v_dialer /usr/add-on/puccase_vob01/ccvob01/v_dialer.vbs public (rep +licated) * /vobs/UMTools /user/addon/puccase_vob01/ccvob01/UMtools.vbs replicat +ed) $ perl extract-vobtags.pl /vobs/bt_rel: /usr/add-on/puccase_vob01/ccvob01/bt_rel.vbs /scm: /usr/add-on/puccase_vob01/ccvob01/scm.vbs /v_dialermidtier: /usr/addon/puccase_vob01/ccvob01/v_dialermidtier +.vbs /v_dialer: /usr/add-on/puccase_vob01/ccvob01/v_dialer.vbs /vobs/UMTools: /user/addon/puccase_vob01/ccvob01/UMtools.vbs

Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!


In reply to Re^3: Problem in pattern matching with alternation by naikonta
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.