in reply to Is there a Better work around rather than 9 If else Looping
Hashes would also solve your multi-if logic.
Here is a structure outline to get you started:
update:minor syntax update, to fix issue described by jdporter, below.my (%user_choice, %audit_rec); # Update: Parens added to fix syntax # Get User input into $user_choice{user}, $user_choice{module} .. and +$user_choice{host} #after reading the record, get it into %audit_rec like this: @audit_rec{ qw| time host user module msg | } = # This is a "Hash-sl +ice" split(']\[|]\s+|^\[',$audit_data); # Now, you can compare $user_choice{xxx} with $audit_rec{xxx} , and l +oop through values for xxx. # A more advanced technique would be to create a "dispatch table" hash + # Search for that on this site, if interested.
"An undefined problem has an infinite number of solutions." - Robert A. Humphrey "If you're not part of the solution, you're part of the precipitate." - Henry J. Tillman
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a Better work around rather than 9 If else Looping
by jdporter (Paladin) on May 23, 2007 at 18:20 UTC |