diff -r 000000000000 -r 9c0f52aa4772 perl/perl-fstab.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/perl/perl-fstab.pl Fri Nov 18 23:07:02 2016 +0100 @@ -0,0 +1,48 @@ +#!/usr/bin/perl + +# Vypíše /etc/fstab ve formě XML souboru. +# +# Závislosti: +# aptitude install libxml-writer-perl + +use strict; +use warnings; + +use IO::String; +use XML::Writer; + +my $xml; +my $output = new IO::String->new($xml); +my $writer = new XML::Writer( OUTPUT => $output, + DATA_MODE => 1, + DATA_INDENT => " "); + +$writer->xmlDecl("UTF-8"); +$writer->startTag("fstab"); + +my $fstab; +open($fstab, "<", "/etc/fstab"); +while (my $r = <$fstab>) { + if ($r !~ /^\x23/ && $r =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$/) { + $writer->startTag("bod"); + $writer->dataElement("zařízení", "$1"); + $writer->dataElement("přípojnýBod", "$2"); + $writer->dataElement("souborovýSystém", "$3"); + + $writer->startTag("volby"); + my @volby = split(",", $4); + foreach my $volba (@volby) { + $writer->dataElement("volba", "$volba"); + } + $writer->endTag(); + + $writer->dataElement("dump", "$5"); + $writer->dataElement("pass", "$6"); + $writer->endTag(); + } +} + +$writer->endTag(); +print $xml; +print "\n"; +