[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] (QXP => HTML) && OOP



Many thanks to Fred and Alan for the suggestions about using a
multi-dimensional hash!

At this point, it seems like the object-oriented approach doesn't have
greater conceptual value, and the object-oriented approach I tried doesn't
seem to work simply.  (Although if Joe or anybody else can help fill in the
blanks on this, I'd be really grateful to get a better on handle on the
proper object-oriented approach to use for this in Perl.)

Based on the hash suggestions, here is a snippet that sets values for two
style sheets and demonstrates that you can always refer to either.  (The
NAME field is probably redundant...):

--------- Start Snippet --------------
#!/usr/bin/perl -w

use strict;

my %Style_Sheets;
my ($Style_Name, $Style_Size, $Style_Font);

$Style_Name = "Body_Text";
$Style_Size = 12;
$Style_Font = "Times";

&create_style_sheet;

$Style_Name = "Head";
$Style_Size = 18;
$Style_Font = "Helvetica";

&create_style_sheet;

$Style_Name = "Body_Text";

print "Style sheet \"", $Style_Sheets{$Style_Name}{NAME}, "\" has a point
size of ",
 $Style_Sheets{$Style_Name}{SIZE}, " and uses ",
$Style_Sheets{$Style_Name}{FONT}, ".\n";


sub create_style_sheet {

	$Style_Sheets{$Style_Name}{NAME} = $Style_Name;
	$Style_Sheets{$Style_Name}{SIZE} = $Style_Size;
	$Style_Sheets{$Style_Name}{FONT} = $Style_Font;

	print "Style sheet \"", $Style_Sheets{$Style_Name}{NAME}, "\" has a point
size of ",
	 $Style_Sheets{$Style_Name}{SIZE}, " and uses ",
$Style_Sheets{$Style_Name}{FONT}, ".\n";

}
--------- End Snippet --------------


Richard

__________________________
Richard Pfeiffer <pfeiffer@well.com>
Publishing Automation/Database Consulting/Book Production
BMUG Scripting SIG -- Next Meeting:
Monday 4/21/97, BMUG offices @ 6:00 p.m.