What do you mean with "formatted text"? That you get a lot of spaces? That's because you have those spaces in your string values for 'body'. If you want a newline you must use \n as in your second example, Perl doesn't care about newlines you used to format the script in which you defined the data structure.
But there are some other issues here:
- your array seems to contain hashes with a single key ('Body'). If there are no other keys then you don't want an array of hashes, you want an array of arrays but maybe that's just the case in your short exapmle here? Is it possible that 'Body' is the name of a workflow? In that case you want a hash of arrays
- you probably don't want the formatting ()newlines, spaces) in your strings at all. A data structure should store data. formatting should be done at the point of consumption of the data structure. For exmaple: if you need to print the data structure as a list in HTML you want to wrap each element in list tags. If you want to dump it to the command line, you want to add newlines at the end of each string. Try to separate data from presentation. Feel free to ask if you need more details about this.
- the actual strings ("1. Blah..") you are storing there represent an ordered list, therefore you should store them as an array, not one long string as you do now.
In short, I think this is what you should have:
my %workflows = (
'workflow1' => [ "first step", "second step", "third step" ],
'workflow2' => [ "first step", "second step", "third step" ],
);
Print a workflow to the command line:
print "Workflow1 is:\n" . join("\n", @%{$workflows{'workflow1'}})."\n"
+;
I hope that helps to get you started - welcome to Perl!