# for example: use strict; use warnings; my $CSS = ""; my $filename = shift (@ARGV) || die ("No file in \@ARGV!"); open ("FILE", "< $filename") or die ("Cannot open $filename $!"); $CSS .= $_ while (); close ("FILE") or die ("Cannot close $filename $!"); # CSS is of the form: # H1 { /* CSS */ } # where H1 is the HTML element # what's in {} is what to do # and /* */ is comments # so get rid of comments $CSS =~ s[/\*.*?\*/][]sg; # now get what's in between the {}s my @parts = split /\}/, $CSS; while (@parts) { my $part = shift (@parts); # now we should have CSS of the form # H1 { directives my ($HTML_element, $CSS) = split /\{/, $part, 2; # note that the HTML element we're working on is in # $HTML_element # now get the CSS directives my @directives = split ';', $CSS; # now each CSS directive i.e. # font-family: Verdana, Arial, Geneva # has been brokon off foreach my $directive (@directives) { my @parts = split ':', $directive; # $parts[0] is font-family my @fonts = split ',', $parts[0]; # @fonts is all the different font families } }