#! /usr/bin/perl -w # $Id$ # $URL$ # # converteer iets als: # [language] # aar: Afar # aa: Afar # abk: Abkhazian # ab: Abkhazian # # naar # [language] # Abkhazian = # abk # ab # # Afar = # aar # aa # use strict; use warnings FATAL=> 'all'; use Data::Dumper; $Data::Dumper::Indent = 1; # mild pretty print my $h = {}; my @file = (<>); main(); sub printSection{ foreach my $k (sort keys %$h){ print "$k =\n "; print join ("\n ", sort @{$h->{$k}}); print "\n\n"; } } sub main{ # N.B.: Comments blijven niet noodzakelijk op hun plek... for (@file) { if (/^#/) { print; next; } chomp; my ($section) = /\[ ([^\]]+) \]/x; if (defined($section)){ printSection(); $h = {}; print "$_\n"; }else { if (/:/) { # format is # value:key # waarbij key herhaald wordt my ($value,$key) = split (/\s*\:\s*/,$_); # zet ' ' terug als die uit http:// verdwenen was ;) $value =~ s{http //}{http://}gi; push( @{$h->{$key}}, $value) } } } printSection(); }