On Tuesday, Sep 10, 2002, at 07:53 US/Pacific, Mike Singleton wrote:

> Something like this then???
>  === Start ===
> use constant JOBSTART => 'SNBJH_3203J';
> #  Condense start
> use constant CONDSTART =>  'SNBJH_3403';
> #  Job end
> use constant JOBEND  => 'SNBJH_3211J';
> #  Condense end
> use constant CONDEND =>  'SNBJH_3401J';
> #  Job cancelled
> use constant JOBCANC =>  'SNBJH_3258J';
> #  Job fail
> use constant JOBFAIL => '-1';
> #  Volsers used
> use constant VOLUSED =>  'SNBJH_3320J';
>
> my %statcode = (
>       JOBEND  =>  0
>       CONDEND =>  0
>       JOBFAIL => -1
>       JOBCANC => -2
>   );
> === End===

you need ',' after the entries above....

[..]
mike I guess a part of the questions are

        a) how are you planning to access your hash %statcode

        b) how dynamic does the reltationship between the 'variables'
                you want to have as constant have to be to the stuff
                you 'stuff' into the hash?

eg:  what do you expect of the following code fragment
assuming that we used your hash and constants....

        my $bob = JOBEND ;
        
        if ( exists ($statcode{ JOBEND } ) ){
                print " have : $bob $statcode{ JOBEND }\n";
        } else {
                print "not in play";
        }

I think what you may really want is

        my %key_words = (
                 SNBJH_3203J    => 'JOBSTART',
                 SNBJH_3403     => 'CONDSTART',
                 SNBJH_3211J    => 'JOBEND',
                 SNBJH_3401J    => 'CONDEND',
                 SNBJH_3258J    => 'JOBCANC',
                 SNBJH_3320J    => 'VOLUSED',
                 -1                             => 'JOBFAIL',
        );

so that you can do

        my $key = some_function();
        if ( exists($key_word{$key}) &&
                exists(statcode{ $key_word{$key}) )
        {
                return($statcode{$key_word{$key});
        }else{
                # either this is a keyword we do not know about
                # eg it is not in our %stat_code
                # OR we have a key returned that is not in our %keywords
                # and need to do some more processing
        }
        

ciao
drieux

---


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to