#!/usr/local/bin/pugs my $input_file = 'dealers.txt'; my $in = open $input_file or die "open($input_file): $!"; my $region = ''; for =$in { if m:perl5/^([a-zA-Z ]+):\s*$/ { $region = $0; next; } if m:perl5/^(\w+)\s+(\w+)\s+(\S*?@\S+)\s+(\d+(?:\s+\d+)*)/ { print "INSERT INTO dealer VALUES (", "{ $/.map:{"'$_'"}.join(', ') }, '$region');\n"; } }