Source

shlomi-fish-homepage / bin / find_ascii_quotes.pl

Full commit
Shlomi Fish 44c7eaf 
shl...@iglu.org.… 7b03bb9 










shl...@iglu.org.… 6dfcb32 

shl...@iglu.org.… 7b03bb9 



shl...@iglu.org.… 6dfcb32 
shl...@iglu.org.… 7b03bb9 






















#!/usr/bin/perl

use strict;
use warnings;

use XML::LibXML;
use XML::LibXML::Reader;
use XML::LibXML::XPathContext;
use Getopt::Long;

my $out_fn;

binmode STDOUT, ":utf8";

# Input the filename
foreach my $filename (@ARGV)
{
    my $reader = XML::LibXML::Reader->new(
        location => $filename, load_ext_dtd => 1, 'no_network' => 1,
    ) or die "Cannot read '$filename'.";
    while ($reader->read())
    {
        if ($reader->nodeType() == XML_TEXT_NODE)
        {
            my $data = $reader->value;

            my @lines = split(/\n/, $data, -1);

            foreach my $idx (0 .. $#lines)
            {
                my $line = $lines[$idx];

                if ($line =~ m{"})
                {
                    printf {*STDOUT} ("%s:%d:%s\n",
                        $filename, $reader->lineNumber()+$idx, $line
                    );
                }
            }
        }
    }

}