#!/usr/bin/perl $var = 1; $varname = "var"; @lines = ; $max = scalar(@lines); $i = 0; print "\n"; print "\n"; print "\n"; while ($i < $max) { $matched = 0; $caption = $lines[$i]; chomp($caption); if ($caption =~ m/^\#/) { $caption = ""; } if ($caption) { $name = "$varname$var"; $i++; $line = $lines[$i]; if ($line =~ m/\.\./) { # assume LICKERT ($left, $mid) = split(/\./, $line, 2); $mid = "." . $mid; $left =~ s/\ +$//; $right = $mid; $right =~ s/^\.+//; $steps = length($mid) - length($right); chomp($right); $right =~ s/^\ +//; $right =~ s/\ +$//; print " \n"; $i++; $line = $lines[$i]; chomp($line); while ($line && ($i < $max)) { print " Junk at line $i: \"$line\"\n"; $i++; $line = $lines[$i]; chomp($line); } $matched = 1; } if ($line =~ m/\_/) { # assume TEXT print " \n"; $i++; $line = $lines[$i]; chomp($line); while ($line && ($i < $max)) { print " Junk at line $i: \"$line\"\n"; $i++; $line = $lines[$i]; chomp($line); } $matched = 1; } if ($line =~ m/^\*/) { # assume CHOICE print " \n"; $line = $lines[$i]; chomp($line); $val = 1; while ($line && ($i < $max)) { $line =~ s/\*//g; $line =~ s/^\ +//; $line =~ s/\ +$//; print " \n"; $val++; $i++; $line = $lines[$i]; chomp($line); } print " \n"; $matched = 1; } if ($line =~ m/^\-/) { # assume LIST print " \n"; $line = $lines[$i]; chomp($line); while ($line && ($i < $max)) { $line =~ s/^\ +//; $line =~ s/^\-//g; $line =~ s/^\ +//; $line =~ s/\ +$//; print " \n"; $i++; $line = $lines[$i]; chomp($line); } print " \n"; $matched = 1; } if (!$matched && $line) { if (!($line =~ m/^\#/)) { chomp($line); print " Unparseable line $i: \"$line\" (caption was \"$caption\")\n"; } } if ($matched) { $var++; } } $i++; } print "\n";