#!/usr/local/bin/perl # Creates Yellow Pages from specially formatted file. # Copyleft(L) Igor Chudov, 1995 # # WARRANTY: See GNU Public License. In short: who the # hell cares what you do with it... # $SOURCE="$ARGV[0]"; $CONTENTS="contents"; $BODY="body"; ##################################################################### Error # Reports error and exists with exitcode != 0 # sub Error { local( $msg ) = pop( @_ ); print STDERR "$Error: $msg\n"; exit( 1 ); } ######################################################### ProcessPerson # Prints out HTML code for one person. # sub ProcessPerson { local( $HREF ) = $URL ? $URL : "mailto:$Email"; $Entry = "
$Name \n" . " \n<$Email> \n"; if( $URL ) { $Entry .= "[ Home Page ]\n"; } if( $Picture ) { $RealPicture = "../../../images/active/scs-folks/$Picture"; if( $Picture =~ /:/ ) { $RealPicture = $Picture; } $Entry .= "[ " . " Picture ]

\n"; } if( $Phrase ) { $Entry .= "$Phrase"; } $Entry .= " \n\n"; push( @Entries, $Entry ); } ################################################################### Prepare # Reads source file and processes everybody. # Stores the results in memory for alphabetical sorting by last name. # sub Prepare { open( BODY, "> $BODY" ); open( CONTENTS, "> $CONTENTS" ); open( PEOPLE, "$SOURCE.lst" ); while( ) { if( /^@@@@/ ) { &ProcessPerson; $Name = ""; $Email = ""; $URL = ""; $Picture = ""; $Phrase = ""; $InPhrase = ""; } elsif( /^Name/ ) { s/^Name *//; $Name = $_; chop( $Name ); @names = split; $LastName = pop( @names ); s/ /_/g; $Label = $_; } elsif( /^Email/ ) { s/^Email *//; $Email = $_; chop( $Email ); } elsif( /^URL/ ) { s/^URL *//; $URL = $_; chop( $URL ); } elsif( /^Picture/ ) { s/^Picture *//; $Picture = $_; chop( $Picture ); } elsif( /^Phrase/ ) { $InPhrase = 1; } elsif( $InPhrase ) { $Phrase = $Phrase . $_; } else { &Error( "Unknown field in $_" ); } } close( PEOPLE ); close( CONTENTS ); close( BODY ); } ##################################################################### Output # Prints the result out along with header # sub Output { system( "cat white-pages.hdr\n" ); print sort( @Entries ); } ################################################################# main # Does the job # &Prepare; &Output; system( "rm -f $BODY $CONTENTS" );