Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

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

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
CODER
Asked:
CODER
  • 4
  • 2
1 Solution
 
maneshrCommented:

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
 
CODERAuthor Commented:
#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
 
maneshrCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
maneshrCommented:
did you try the code??

did it work for you??

let me know. :-)
0
 
CODERAuthor Commented:
yes it worked thanks...
0
 
maneshrCommented:
were you looking for specific solution??

wasnt the solution i provided up to your expectations??

let me know.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now