Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/thread-self/root/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/thread-self/root/bin/srx2csv
#!/usr/bin/perl -l

use strict;
use warnings;
use RDF::Trine;
use Text::CSV_XS;
use Scalar::Util qw(reftype blessed);

my $fh;
if (scalar(@ARGV) and -r $ARGV[0]) {
	my $file	= shift;
	open($fh, '<:encoding(UTF-8)', $file) or die $!;
} else {
	$fh	= \*STDIN;
}

my $csv		= Text::CSV_XS->new ( { binary => 1 } );
my $handler	= RDF::Trine::Iterator::SAXHandler->new( sub {
		our @keys;
		my $vb	= shift;
		if (reftype($vb) eq 'ARRAY') {
			@keys	= @$vb;
			$csv->print( \*STDOUT, \@keys );
		} else {
			print_vb( $csv, $vb )
		}
	},
	{
		variables => 1
	}
);

my $p		= XML::SAX::ParserFactory->parser(Handler => $handler);
$p->parse_file( $fh );



sub print_vb {
	our @keys;
	my $csv	= shift;
	my $vb	= shift;
	$csv->print( \*STDOUT, [ map { blessed($_) ? $_->value : '' } @{ $vb }{ @keys } ] );
}

Hry