Skip to content

Instantly share code, notes, and snippets.

@saitoha
Created April 23, 2012 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saitoha/2470392 to your computer and use it in GitHub Desktop.
Save saitoha/2470392 to your computer and use it in GitHub Desktop.
きのう書いたやつ
#!/usr/bin/env perl
my %bank = ();
my $i = 0;
open (IN, $ARGV[0]) or die "cannot open specified file.";
foreach $line (<IN>) {
if ($line =~ /^"(..) c (#[A-Z0-9]{6})"/) {
$bank{$1} = $i;
print "\e]4;$i;$2\e\\";
$i++;
} elsif ($line =~ /\"(.+)",/) {
foreach $c ($1 =~ /../g) {
print "\e[48;5;", $bank{$c}, "m ";
}
print "\n";
}
}
close (IN);
=head1 EXAMPLES
> xpm2term.pl sample.xpm
=head1 AUTHOR
saitoha <<user@zuse.jp>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment