Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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...

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.

¤


In reply to By the numbers reports by frankus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (6)
    As of 2018-10-16 02:37 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      When I need money for a bigger acquisition, I usually ...














      Results (82 votes). Check out past polls.

      Notices?