#!/bin/perl use SVG; use strict; use XML::XPath; use XML::XPath::XMLParser; my $file = 'world.svg'; my $xp = XML::XPath->new(filename => $file); my ($codefile,@codes); my $svg = SVG->new(width=>1000,height=>1000); my $svgfh; #posunutia a zvacsenie my $width_translate = -300; my $height_translate = 0; my $scale = 1; open($svgfh,"+>europe.svg") or die $!; #nacitame si krajiny open($codefile,"; foreach my $code (@codes){ #zoberieme si len kod krajiny my $code = substr($code, 0, 2); my ($value, $style, $d); foreach my $node ($xp->find('/svg/g')->get_nodelist){ my $found = 0; foreach my $metadata ($node->find('metadata/AMP_attribute')->get_nodelist){ $value = $metadata->find('@value'); if("$value" eq $code){ $found = 1; last; } } if($found){ $style = $node->find('@style'); $d = $node->find('path/@d'); $svg->path( style=>''.$style.'', d=>''.$d.'', transform=>'matrix('.$scale.',0,0,'.$scale .','. $scale*$width_translate. '#,'.$scale*$height_translate.')'); } } } my $out = $svg->xmlify; print $svgfh $out; #print $out; __END__