#! /usr/local/bin/perl use strict; use warnings; # $i: italic # $s: shadowed # $w: wide spacing # $n: narrow spacing # $m: normal setting # $g: default color # $t: changes the text to capitals # $z: reset all # $$: to write a "$" my %classes = ( i => 'italics', s => 'shadowed', w => 'wide', n => 'narrow', m => 'normal', ); foreach ( '$iMy$z$w$f00Nickname', '$s$5aaD$ddfia$5aaD$ddfe$5cc§', '$iT$sh$wi$ns is $m$444silly$z $tsmall stuff$z and BIG STUFF', '$wWIDE$nNARROW$mnormal', ) { my $string = $_; my @tags; while ( $string =~ m/(\$[iswnmgtz\$]|\$[0-9a-f]{3,3})/ig ) { my $c = lc(substr($1,1,1)); if(my $class = $classes{$c}) { substr($string,pos($string) - 2, 2, ""); push(@tags, ''); } elsif($c eq 'g') { substr($string,pos($string) - 2, 2, ''); push(@tags, ''); } elsif($c eq 't') { my $end = index($string, '$z', pos($string)); $end = length($string) if($end == -1); substr($string,pos($string)-2 ,$end - pos($string) +2, uc(substr($string,pos($string), $end - pos($string)))); } elsif($c eq 'z') { { local $" = ""; substr($string,pos($string) - 2, 2, "@tags"); } @tags = (); } elsif($c eq '$') { substr($string,pos($string) - 2, 2, '$'); } else { my ($x, $r, $g, $b) = split(//,$1); substr($string,pos($string) - 4, 4, ""); push(@tags, ''); } } { local $" = ""; $string .= "@tags"; } print "$string\n"; }