This technique is more general than just for config files which is why I'm not using Config::Any in this example.
I have a config file with lines like this:
userid foo-admin # foo-comment
directory /some/dir # bar-comment
And I'm using some very awkward code to get the values.
my @userline = grep /userid/, <$configfh>;
my @userparts = split(' ', $userline[0]);
my @user = $userparts[1];
seek($configfh, 0, 0);
my @pathline = grep /directory/, <$configfh>;
my @pathparts = split(' ', $pathline[0]);
my $path = $pathparts[1];
It works! But man, is it ugly. There's got to be a clearer way to extract the values I want from the file.