Hi Perl Monks.... Can any one one help me how to do the following. 1. I Will be receiving one of the below values(mentioned in Examples) +in the string and I need to find whether the string starts with one o +f : MS_ , TS_ , BP_ , Dummy_ and ends with one of _0001, _025f(alpha +numeric) OR _0001_678b, _0001_7d18,_0001_a6d8 (_0001_XXXX ) : XXXX is any decimal number or alphanumeric. 2. Also i need to store the second string(11BT801) i.e after MS_,TS_,B +P_,Dummy_ to some variable. ----------Examples----------- MS_11BT801_AQHT801_0001 TS_11BT801_AUBT801_0001 BP_11BT801_C2DT801_0001 BP_11BT801_DNWT801_025f Dummy_11BT801_CPZT801_3h81 MS_C2DT801_PU7T801_0001_678b TS_C2DT801_RAYT801_0001_7d18 BP_CJBT801_NKRT802_0001_a6d8
sub _print_nodeandip { my @ips; if(! open (FILE_FH, "$File")) { print "Failed to Open File $File for Reading.. Exiting.."; exit; } while (<FILE_FH>) { chomp($_); my @line = split(/,/,$_); my $node=$line[1]; if ($node =~ /[A-Za-z]\_*\_*\_*\[A-Za-z0-9]/) { print "$node\n"; } } my Input Line has something like : 11bt801,MS_11BT801_5A0T801_0001,3,10.197.28.38,11BT801,1,16,1,1,3,10.1 +97.28.37,mtx1.idc

In reply to String with multiple underscores by sgowrish

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.