User Tools

Site Tools


perl:ansi_color

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ansi_color [2009/07/22 13:33] – created tkbletscperl:ansi_color [2009/09/04 09:20] (current) tkbletsc
Line 4: Line 4:
 sub ansi { sub ansi {
  my ($c) = @_;  my ($c) = @_;
- if (!$c) { return '\e[m'; }+ if (!$c) { return "\e[m"; }
  my %colors = qw(  my %colors = qw(
  reset       0  reset       0
Line 29: Line 29:
  on_white   47  on_white   47
  );  );
- my $r = join(';',map {$colors{$_}} split(/\S+/,$c)); + my $r = join(';',map {$colors{$_}} split(/\W+/,$c)); 
- return $r ? "\e[${r}m" : '';+ return length($r? "\e[${r}m" : '';
 } }
 </code> </code>
perl/ansi_color.1248294828.txt.gz · Last modified: 2009/07/22 13:33 by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki