Unless I am missing something... it looks as if you are compairing quoted strings and not variables.
('ShowPersonal' eq 'Personal')
will never evaluate to true. without seeing more of your code I can only guess that you either mean
($showpersonal eq 'Personal')
and hopefully not
('$showpersonal' eq '$personal')
there is a very big difference between what you have and the two examples that I have shown. Mine use variables, which, hopefully would be modified in your program, so that they would contain the values of something useful to compare, and in the second example that I give, you are compairing the quoted string $showpersonal and $personal, not the two variables $showpersonal and $personal.
here are some good documents that you may want to look over, and you might also consider posting more of the code that you are working with.
check this out and perhaps this as well.
good luck! | [reply] [d/l] [select] |
Actually, I am comparing the string to a value from a key in a hash so here is some more code:
foreach $key (%hash) {
if ($key{Value} le $variable) && (($key{Value1} eq 'String') && ($key{
+value2} eq 'String1')) {
Do this....
}
Does this look any better? | [reply] [d/l] |
Your code iterates over the keys and values of the hash one at a time, putting the result into $key, a scalar variable. Then it looks in a hash named %key... I think that what you really want is:
foreach $currentkey (keys %hash) {
}
(If you're cool with $_, you can leave out $currentkey in that incantation.) I can't figure out exactly what you want in the comparison, though. $hash{$currentkey} will give you the value associated with the key currently in consideration. To get the hash value for another value, you can use $hash{'key_name'} if you are referring directly to a string value for the key, or $hash{$value1} if the variable $value1 contains the name of that key.
| [reply] [d/l] |
Mind your parentheses. Make sure your date format compares
properly with a string compare ("2001-05-15" will, but
"15 May 2001" and "2001-5-15" won't). What exactly is the
problem you're having with this code?
| [reply] |
Have you even tried this code? Have you read up on how hashes work? This is sounding very much like you have a vague idea of what you want to do and are trying to get the people on perlmonks to figure out your implementation for you. That's why I --'ed you, by the way. Do your own legwork, then come here when you cannot figure out on your own what's going on. That means after you've gone through the Camel book and tried different iterations on your own. | [reply] |