#!/usr/bin/perl -w # Example code to extract RIG* constants from the Hamlib namespace use Hamlib; # Here the goal is to grab the rig model name constants from the Hamlib # namespace and put them into a list so we can select one to pass to the # 'new' Rig constructor. We can do this to extract mode names, etc. # %Hamlib:: is a hash containing all of the values (variables, constants, # functions, etc.) imported into the Hamlib namespace. foreach (sort keys %Hamlib::) { if (m/^RIG_MODEL_.*/) { push(@rigs, $_); } if (m/^RIG_MODE_.*/) { push(@modes, $_); } } # and print them out in a nice sorted list, or whatever needs to be done print "Model Hamlib Name\n"; foreach (sort @rigs) { ($rig = $_) =~ s/^RIG_MODEL_//; printf STDOUT "%-20s%-20s\n", ($rig, $_); } print "\n\nMode Hamlib Mode Name\n"; foreach (sort @modes) { ($mode = $_) =~ s/^RIG_MODE_//; printf STDOUT "%-10s%-10s\n", ($mode, $_); }