my $commentcol = 30;

my (@lines) = (";komentar - prva linija\n",
   	       "1234 X200.18Y50.41Z42.78\n",
   	       "5678 Y=452.54 Z28.10  X=94.75\n",
   	       "90 Z=12.689 Y87.91  X42.58\n",
   	       ";komentar - zadnja linija\n");

{ print <<HEADER; }
/* generirani podaci */

HEADER

print "Lines:\n";	#lines
for (@lines)
{     chomp;
      s/\r//;
      my $line = $_;	#$line je procitana linija
      my $code = '  ';
      my $data = $line;
      print "WHILE\n\n";
      print "\$data\@start = ".$data."\n\n";
      while ($data =~ s/(X=?\d+\.?\d+|Y=?\d+\.?\d+|Z=?\d+\.?\d+)//)
      #while ($data =~ s/(X=?\d+\.?\d+)|(Y=?\d+\.?\d+)|(Z=?\d+\.?\d+)//)
      {
      	print "\$data = ".$data."\n\n";		#nakon 'vadjenja' broja
      	print "\$1 = ".$1."\n\n";
      	print "\$2 = ".$2."\n\n";
      	print "\$3 = ".$3."\n\n";
      }
      print "END WHILE\n\n";
      $code .= ' 'x($commentcol-length($code));		#ubaci razmake
      $code .= "( $_ )\n";				#procitana linija
      print $code;					#ispisi liniju
}