sgowrish has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: String with multiple underscores
by bellaire (Hermit) on Mar 05, 2009 at 22:08 UTC | |
|
Re: String with multiple underscores
by jwkrahn (Abbot) on Mar 05, 2009 at 23:26 UTC | |
by Anonymous Monk on Mar 06, 2009 at 15:30 UTC | |
|
Re: String with multiple underscores
by Corion (Patriarch) on Mar 05, 2009 at 21:53 UTC | |
|
Re: String with multiple underscores
by CountZero (Bishop) on Mar 06, 2009 at 06:28 UTC |