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); my @user = $userparts; seek($configfh, 0, 0); my @pathline = grep /directory/, <$configfh>; my @pathparts = split(' ', $pathline); my $path = $pathparts;
It works! But man, is it ugly. There's got to be a clearer way to extract the values I want from the file.