The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 05-27-2009
KevinADC KevinADC is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2008
Posts: 731
zedex,

what you want to do is use a hash.

Assuming the rest of your code works:

Code:
my %ARG = (
   5 => "ADD ENTRY TO DATABASE",
   6 => "ADD ENTRY TO REG FILE",
   7 => "SHOW DEBUG MSG",
);

foreach $k in (5,6,7) {
{ 
     if ...
     {
      } else 
      { 
             print "$ARG{$k} entry invalid\n" ;      
       }
}
Hashes are a fundamental concept of perl (and other programming languages), you need to read up on them and use them as necessary.