Introduction
In several jobs now, I've realised the importance of numbering sections in test scripts and specifications and stuff to clear up misunderstandings.
But it sure is a pain having to alter text files when someone adds an extra step or section or item...
And cat it through the script like this:
In several jobs now, I've realised the importance of numbering sections in test scripts and specifications and stuff to clear up misunderstandings.
But it sure is a pain having to alter text files when someone adds an extra step or section or item...
So I made this. It took about 30 mins to write and test and it reminded me of all the fun you can have with formats.
Usage
Write a text file like this:
- The firstline is the title of the whole thing.
- a line starting S: is a section header
- a line starting T: is a sub-heading
- plain lines are items with a tick box
Of course it's simple, I am ;)
Example use for script S:Easy to write T:takes little time I tied a file suffix in vim Add a few macros It's a doddle T:I hate using word I hate Microsoft It sucks, for one Okay this isn't great but Did I ever say it was? S:Easy to deploy T:Just wanted to show Several sections in action Yeah it won't stretch over several lines yet :(
And cat it through the script like this:
cat example | ./checklist > output.txt
Feel free to hack it, ransack or ignore it ;)
#!/usr/bin/perl -w use strict; $==shift || 60;# Set lines per page $^='H';# Set header format %_=map{$_,0}('S'..'U'); # Make a list formats my $title=<>; # Set title to first line of input doc # Header format format H= + Page: @>>>> + $% @>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +>>>>>>>>>>>>>>>>>>>>>>>>>>>> + `date` @||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||||||||||||||||||||| $title @||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||||||||||||||||||||| '=' x (length($title)-1) # that or chomp $ti +tle . # Section format format S= SECTION @# : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $_{S}, $_ ====================================================================== +============================ + Use box indicate outcome. . # Test section format format T= @>>>>>>>>>>>>> @#.@# : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<<<<<<<<<<<<<<<<<<< 'TEST',$_{S},$_{T}, $_ . # Item section format format U= @>>>>>>>>>>>>>>>>>>>> @#.@#.@# : @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<<<<<<<<<<<<<<<<<<<<[ ] 'STEP',$_{S},$_{T},$_{U}, $_ . for(<>){ # until EOF chomp; # strip newline ($_,$~)=/:/?($',$`):($_,'U'); # choose format and output line. /\w/ or next; # if it's empty, move on. $_{$~=~/S/?'T':'U'}=0 if $~!~/U/; # Reset the next section counte +r in order $_{$~}++; # increment section counter write; # output template }
--
Brother Frankus.
¤
Back to
Cool Uses for Perl