What you want is to use one of the many templating systems. See Template for a selection of those.
If you're hell-bent on rolling your own, just to keep the precious Perl variables, my suggestion is to declare them explicitly in a hash and to replace them with a tiny loop:
my %template_variables = ( 'navytext' => $navytext, # ... ); my $css = <<'CSS'; #tabmenu { color: #$navytext; } CSS sub fill_template { my( $str, $vars ) = @_; $str =~ s!\$(\w+)!$template{ $1 } || '$' . $1!ge; $str }; print fill_template( $css , \%template_variables );
In reply to Re: Perl variables embedded in CSS in a CSS file not resolving correctly when the file is linked in
by Corion
in thread Perl variables embedded in CSS in a CSS file not resolving correctly when the file is linked in
by craigt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |