<: use utf8; use strict; use warnings; no warnings 'qw'; # you know what you doing no warnings 'uninitialized'; # save some useless checks for more legible code use open IO => ':utf8'; our $style; $header{content_type} = 'text/html; charset=utf-8'; sub stylesheet { my %styles = map {$_ => $_} @_; if (exists $get{style}) { $style = $styles{ $get{style} }; require CGI::Cookie; AddCookie(CGI::Cookie->new( -name => 'style', -value => $style, -path => '/', # site-wide; current page is confusing to most users -expires => $style ? '+5y' : '-1d', )->as_string); } $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $_[0]; return join "\n", map { sprintf( '', $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_ ) } @_; }