#! /usr/bin/perl

# Test file to check certain perl characteristics
# 
# 
# How to access command line. 
# $0 is command name, first argument is $ARGV[0]
# 
open(INF,$ARGV[0]) or die "Can't open input file: $!\n";
open(OUTF, ">$ARGV[1]") or die "Can't open output file $!\n";

while($line = <INF>)
 { if ($line =~/a>/) 
	 { $i = 0;	 
	  chomp($line);	 
	  ($beg,$names) = split("a>. ", $line);
	  print OUTF "$beg a>. ";		 
	  @nombre = split(";",$names);		 
	  foreach $nom(@nombre)
		  { ($ap,$nm) = split(",", $nom);		    
		    if ($i == $#nombre) 
			  {print OUTF "$nm$ap.";}
			 else
			  { $i++;			  
				print OUTF "$nm$ap,";}
	      }
	  print OUTF "\n";	  
     }
  else {print OUTF $line;}  
 }

