http://www.perlmonks.org?node_id=386500

for bart
<!-- xslt 2.0 --> <xsl:choose> <xsl:variable name="output"> <img src="{@src}"/> </xsl:variable> <xsl:when test="@popup"> <a href="{@popup}"> <xsl:copy-of select="$output"/> </a> </xwl:when> <xsl:otherwise> <xsl:copy-of select="$output"/> </xsl:otherwise> </xsl:choose> <!-- xslt 1.0 --> <xsl:choose> <xsl:when test="@popup"> <a href="{@popup}"> <xsl:call-template name="img"/> </a> </xwl:when> <xsl:otherwise> <xsl:call-template name="img"/> </xsl:otherwise> </xsl:choose> <xsl:template name="img"> <img src="{@src}"/> </xsl:template>
xd -- Hexdump
#!/usr/bin/perl @fill= qw( .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ); if (scalar(@ARGV)) { foreach $file(@ARGV) { $size= -s $file; $form= length(sprintf("%x",$size))-1; ++$form unless $form; print "File: ",$file,"\n"; open (IN,$file); &dump(*IN, $form); close (IN) } } else { &dump(*STDIN, 4); } sub dump { local(*IN, $form)= @_; my ($buf, $i); while ($rb= read(IN, $buf, 16)) { @x= unpack("H2" x $rb, $buf); $buf=~ s/[\x00-\x1f\x7f-\xff]/./g; $buf.= ' ' x (16-length($buf)); printf ("%0${form}x0: %s [%s]\n" ,$i++, ,sprintf ("%s %s %s %s %s %s %s %s - %s %s %s %s %s %s %s %s +", @x, @fill) ,$buf ); } }
dx -- undump
#!/usr/bin/perl if (scalar(@ARGV)) { foreach $file(@ARGV) { open (IN,$file); &undump(*IN); close (IN) } } else { &undump(*STDIN); } sub undump { local(*IN)= @_; local($_); while (<IN>) { # next unless s/^([0-9a-f]+)://; s/^([0-9a-f]+)://i; s/[^\-\s0-9a-f].*$//i; @match= /(\b[0-9a-f][0-9a-f]\b)/ig; print pack("H2" x scalar(@match), @match); } }
Unicode "Rotator"
perl -e '$_=<<ROTATOR; 01 01 01 00 00 01 01 01 00 00 01 11 00 00 10 11 00 10 10 10 10 10 10 00 11 10 00 00 11 01 00 00 ROTATOR s/\b(0|1)(0|1)\n(0|1)(0|1)\n(0|1)(0|1)\n(0|1)(0|1)(\n\n)?/0b$8$7$6$4$2 +$5$3$1\n/g; foreach (split /\n/) { printf "\\x{%x}", 0x2800 + eval($_); }'