Hi there,
have this tiny but overly irritating issue where i would like to choose iterated %hash by scalar value. So if $choise variable contains string "computerAttributes", iterate through %computerAttributes. This way i can have only one foreach loop defined in the program, but several hashes to choose from. Must have a brain malfunction or something, but i just can't figure this one out.
#!/usr/bin/perl -w use strict; my $choice = 'computerAttributes'; my %computerAttributes = ( cn => 'Common Name (eg. John Doe)', distinguishedName => 'Computer distinguishedname (dn) representing o +bject location in LDAP-directory', lastLogOff => 'Last time LDAP-directory received logoff message from + system' ); my %userAttributes = ( cn => 'Common Name (eg. laptop1)', sn => 'Surename', displayName => 'First and lastname', title => '' ); foreach (my $key = keys %($choice)) { print "$key\n"; }
In reply to Choosing %hash by scalar value by mellin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |