I have a test generator written in Perl. It generates tests that connect to the simulator. These tests themselves are written in Perl and connected to the simulator through the API. I would like the generated code to be human readable, which means that I would like it to be indented and formatted correctly. Is there a good way to do this?
Details follow, or you can go to the current issue below.
This is an example:
my $basic = ABC TRIGGER => DELAY( NUM => 500, ), ) BASIC my $additional = STATE_IS( STATE => DEF, INDEX => 0, ), ADDITIONAL
I would like to execute the ABC command with a delay of 500 (units are irrelevant just now) after calling &event , and the status of index 0 is DEF . Sometimes I also want to wait for queues 1, 2, 3, etc ...
Only for one index that I would like to see in my test:
&event( CMD => ABC TRIGGER => DELAY( NUM => 500, TRIGGER => STATE_IS( STATE => DEF, INDEX => 0, ), ), )
For two indexes, I would like to see:
&event( CMD => ABC TRIGGER => DELAY( NUM => 500, TRIGGER => STATE_IS( STATE => DEF, INDEX => 0, TRIGGER => STATE_IS( STATE => DEF, INDEX => 1, ), ), ), )
So basically I add a block from
TRIGGER => STATE_IS( STATE => DEF, INDEX => 0, ),
for each index, and the index number changes.
Here is how I do it:
for $i (0..$num_indeces) {
Here is the actual question
The problem is that the code comes out with bad indentation. I would like to run the resulting $basic through a prettifier as follows:
&prettify($basic, "perl");
To format it according to Perl's best practices. Is there a good way to do this?