mirage4d has asked for the wisdom of the Perl Monks concerning the following question:
Greetings all.
There has to be a better way to perform the task below. Essentially I'm just renaming fields returned from an LDAP directory searchfor output - and this works - but there has to be a more efficient way. Using all of these "IF" conditionals seems really clunky. Any suggestions are appreciated. Thanks.
And so on for about ten fields, which makes for a lot of conditionals. Hoping to find a better way.@ldapFields = ("unvLocalPhone", "unvLocalAddress", ...); foreach $field @ldapFields { if ($field eq "unvLocalPhone") { $field = "Phone"; } if ($field eq "unvLocalAddress") { $field = "Address"; } # Many more ifs follow...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A more efficient way to do this?
by kennethk (Abbot) on Feb 11, 2010 at 16:15 UTC | |
|
Re: A more efficient way to do this?
by ikegami (Patriarch) on Feb 11, 2010 at 16:13 UTC | |
|
Re: A more efficient way to do this?
by toolic (Bishop) on Feb 11, 2010 at 16:16 UTC | |
|
Re: A more efficient way to do this?
by Ratazong (Monsignor) on Feb 11, 2010 at 16:22 UTC | |
by GrandFather (Saint) on Feb 11, 2010 at 20:18 UTC | |
by mirage4d (Novice) on Feb 11, 2010 at 21:20 UTC | |
by kennethk (Abbot) on Feb 11, 2010 at 21:34 UTC | |
|
Re: A more efficient way to do this?
by hbm (Hermit) on Feb 12, 2010 at 13:46 UTC |