Solved

Question for you GURU's -- Strings and if construct!!!-thanxs

Posted on 2000-05-02
6
140 Views
Last Modified: 2010-03-05
OK I have another quest:
                      now what if when i run this command thru my script
                      and what gets stored in my variable $label are the following below

                      COL.tvname.igb.appls.slrc-object
                                                                  COL.tvname.xxx.xxxxx.slrc-object
                                                                  COL.tvname.xxx.iiixxxi.slrc-object
                                                                  COL.tvname.igb.appls.slrc-object

                      all gotten from doing this
                      ==================================
                      foreach $label (@RCs[$n])

                      { $label = `idlcall $NROID get_all '"Rcl" 100'; }
                      ==================================
                      now i want to do a check.
                      I want to see if the match a certain criteria and i want to see i wach label has the following attahed to it: igb.appls.slrc-object

                      and if it does do something and if it does not report error to the user,,,
                      how do i go abt writing the if construct..

                      pls i need help ASAP... thanks...
0
Comment
Question by:CODER
  • 4
  • 2
6 Comments
 
LVL 16

Accepted Solution

by:
maneshr earned 50 total points
ID: 2769856

what i am doing is looking in the $label variable and if i get a label that ends with igb.appls.slrc-object i say all is OK.

if not i print Error.


Here is the code snippet. Add this after $label = `idlcall $NROID get_all '"Rcl" 100';

if ($label=~ /^(.*)igb\.appls\.slrc-object$/){
  print "OK!!\n";
}else{
  print "Error\n";
}
0
 

Author Comment

by:CODER
ID: 2769958
#retrieving the label and OID for each Remote Control Entry
foreach $label_and_OID (@RCs[$n])  
{
   $label= `idlcall $NROID get_all '"Rcl" 100'`;
}

now can i stick your above code in my foreach loop or outside the loop

thanks....  i am thinking outside but i DONT WANT TO LOOSE ANY VALUES in the $Label.
what do u think? thanks...
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2770081
there you go. now that should work.

the if statement that i have provided, uses $label in a READ-ONLY context. Therefore you will NOT loose anything from $label.

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Expert Comment

by:maneshr
ID: 2778921
did you try the code??

did it work for you??

let me know. :-)
0
 

Author Comment

by:CODER
ID: 2780948
yes it worked thanks...
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2781001
were you looking for specific solution??

wasnt the solution i provided up to your expectations??

let me know.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
perl match and sort unique result 2 129
Strange perl issue 6 126
quoting a comma separated list 20 82
Control Number of Log Files -Perl 7 55
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now