You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
737 B
Perl

#!/perl/bin/perl
use warnings;
use strict;
print <<'HEADER';
Content-Type: text/xml
<?xml version = "1.0"?>
HEADER
print( "<contacts>\n\n" );
open( NAMES, "names.txt" ) or die ( "Error opening names.txt" );
while ( <NAMES> ) {
chomp;
# escape any characters not allowed in XML content.
s/&/&amp;/;
s/</&lt;/;
s/>/&gt;/;
s/"/&quot;/;
s/'/&apos;/;
my ( $last, $first ) = split( /, / );
print( " <contact>\n",
" <LastName>$last</LastName>\n",
" <FirstName>$first</FirstName>\n",
" </contact>\n\n" );
}
close( NAMES );
print( "</contacts>\n" );
#File: names.txt
# Jack, John
# Jason, Sue
# Jodd, Bob