wrapit5.pl -- Wrap Fixed-Format Variable Statements


This Perl script reads a file containing a column of SAS Input or SPSS Data List statements and reformats them into a wrapped format with multiple fields per line--defaulting to five columns wide. Handy for making long, single-column declarations more compact and readable in your code.

Usage

The command line is: perl wrapit5.pl filename >filename.out
Here is an example. Consider this input data:



Sample input (cards):

  V1 1-4
  V2 5-8
  V3 9-9
  V4 10-13
  V5 14-14
  V6 15-16
  V7 17-17
  V8 18-19
  V9 20-21

The command perl wrapit5.pl cards > cards.wrap produces this:

 Sample output (cards.wrap):

    V1 1-4         V2 5-8         V3 9-9         V4 10-13       V5 14-14
    V6 15-16       V7 17-17       V8 18-19       V9 20-21       


Back to Kent's Perl Page