cPanel has a set of functions built in to load configuration files. To load up a cPanel based YAML datastore, use Cpanel::CachedDataStore::loaddatastore like so:
Code:
my $username = 'someuser';
my $configFile = '/var/cpanel/userdata/' . $username . '/main';
my $configData = Cpanel::CachedDataStore::loaddatastore( $configFile, 0 );
Then, you can access the different parts of $configData->{data} to get your variables:
Code:
#subdomains:
my @subdomains = $configData->{data}->{sub_domains};
#parked domains:
my @parked_domains = $configData->{data}->{parked_domains};
Though, if you're looking to gather this data, there's probably a better way to get what you want from within cPanel's code base. Look around in /usr/local/cpanel/Cpanel and you'll find tons of useful modules.