[comp.lang.perl] need AWK help: lowercase, trim trailing spaces

merlyn@iwarp.intel.com (Randal L. Schwartz) (04/21/91)

In article <1817@wjvax.UUCP>, mario@wjvax (Mario Dona) writes:
| HELP! I have a situation that just cries out for an awk solution, however
| I'm at a loss over some minor, but important details.

Well, to *me* it just cries out for a Perl solution.  Try this:

while (<>) {
	s/([A-Z]{3,})/\u\L$1$2/g;
	($name,$address1,$address2,$city,$zip) = unpack("A10A19A17A24A*",$_);
	print "$name\n";
	print "$address1\n";
	print "$address2\n" if $address2;
	print "$city $zip\n";
	print "\n";
}

Works just fine on your test data.

print "Just another Perl hacker,"
-- 
/=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\
| on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III      |
| merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn |
\=Cute Quote: "Intel: putting the 'backward' in 'backward compatible'..."====/