Can any one suggest me how can I read this hash of config file into my script?
There are a number of common configuration file formats, and some of them can represent arbitrarily nested structures. YAML and JSON appear to be quite popular now.
Of course, your data structure is still inappropriate for the data is contains. What you posted has a lot of unrelated data at the same level:
my %CFG = (
Command => [
"DES",
"Copy",
"CMD",
"cp file1 file2'Hello'",
"DES",
"Remove",
"CMD",
"rm file1",
"DES",
"View",
"CMD",
"vi file1",
],
);
Instead, I'd recommend:
my %CFG = (
Command => [
{ DES => "Copy", CMD => "cp file1 file2'Hello'" },
{ DES => "Remove", CMD => "rm file1" },
{ DES => "View", CMD => "vi file1" },
],
);
|