Created
June 18, 2009 18:10
-
-
Save EvanCarroll/132074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package XML::SAX::Debian; | |
use strict; | |
use warnings; | |
use base 'XML::SAX'; | |
use File::Spec; | |
our $VERSION = '0.01'; | |
sub save_parsers { | |
warn "\n"; | |
warn "Please use 'update-perl-sax-parsers(8) to register this parser.\n"; | |
. "See /usr/share/doc/libxml-sax-perl/README.Debian.gz for more info.\n"; | |
. "XML::SAX::save_parsers call is short circuited\n" | |
; | |
} | |
sub save_parsers_debian { | |
my $class = shift; | |
my ($parser_module,$directory, $priority) = @_; | |
# add parser | |
$known_parsers = []; | |
$class->add_parser($parser_module); | |
# get parser's ParserDetails file | |
my $file = $parser_module; | |
$file = "${priority}-$file" if $priority != 0; | |
$file = File::Spec->catfile($directory, $file); | |
chmod 0644, $file; | |
unlink($file); | |
my $fh = gensym(); | |
open($fh, ">$file") || | |
die "Cannot write to $file: $!"; | |
foreach my $p (@$known_parsers) { | |
print $fh "[$p->{Name}]\n"; | |
foreach my $key (keys %{$p->{Features}}) { | |
print $fh "$key = $p->{Features}{$key}\n"; | |
} | |
print $fh "\n"; | |
} | |
print $fh "\n"; | |
close $fh; | |
return $class; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment