Parsing dfm report -F perl
2011-06-27 01:11 AM
I want to export some DFM data using the database:
dfm database query run -F perl "SELECT * FROM objectview"
It returnes following datatructure:
@queryColumns = (
@queryData = (
How can I transfer this into a hash? I don't want to parse it as text.
1 REPLY 1
Re: Parsing dfm report -F perl
2012-10-08 05:43 AM
your post is now more than 15 month old, but still unanswered.
I faced the exact same problem recently and thought I'll share the solution as soon as I found it.
Maybe it still helps you or at least others who want to directly process the dfm perl output.
Use the "eval()" function and run the command as argument (don't forget the backticks)
eval(`dfm database query run -F perl "SELECT * FROM objectview"`);
This will force your perl script to interpret the output of the dfm command as actual perl code and execute it.
Afterwards you'll have the hashes "@queryColumns" and "@queryData" directly available within the initial script.
You may have to define the hashes first so that they are known to the script.
This works for all dfm commands where the output can be formatted as "perl".
I e.g. used it with the report command and data:
# explicitely define the following variables as they are used
# within the report so that the output can be processed
my (%reportData, @reportKeys, $reportFormatVersion, $reportCommandVersion, %report, @reportColumnKeys, %reportColumns, %reportSummary);
my $reportOutput = `dfm report view -F perl $report $resGrp`;
eval($reportOutput) || die ("ERROR: There is no resource group with ID $resGrp \n");