$_=~ tr/upload='true'/upload='false'/;
Quote<osm version='0.6' upload='true' generator='JOSM'>
-> <osm vsasion='0.6' upload='faus' gsnsaafoa='JOSM'>
Quoterue' version='4' changeset='6456424' lat='36.7256674' lon='-4.4539391' />
1 2 3
my $text = "upload='true'"; $text =~ s/upload='true'/upload='false'/; print $text;
1 2 3
my $text2 = "rue' version='4' changeset='6456424' lat='36.7256674' lon='-4.4539391' />"; my ($latval) = $text2 =~ m/lat='(\d+\.\d+)/; print $latval;
1 2 3 4
my $text3 = "rue' version='4' changeset='6456424' lat='36.7256674' lon='-4.4539391' />"; my $newlatval = 32.476652; $text3 =~ s/lat='(\d+\.\d+)/lat='$newlatval/; print $text3;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/perl use strict; use warnings; use utf8; my $daten; open (DATEI, "test.osm") or die $!; while(<DATEI>){ print $_."\n"; $_ =~ s/upload='true'/upload='false'/; # Auslesen der Koordinaten my ($lat_old) = $_ =~ m/lat='(\d+\.\d+)/; my ($lon_old) = $_ =~ m/lon='(\d+\.\d+)/; if (defined ($lat_old) && defined ($lon_old)){ print "my lat= ".$lat_old." lat= ".$lon_old."\n"; } } close (DATEI);
QuoteE:\osm_drehen>perl osm-rotate.pl
<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' upload='true' generator='JOSM'>
<bounds minlat='36.7058616' minlon='-4.4556427' maxlat='36.7449367' maxlon='-4
.3629456' origin='CGImap 0.1.0' />
<node id='13838066' timestamp='2010-11-25T18:18:48Z' uid='267081' user='Habbit
' visible='true' version='4' changeset='6456424' lat='36.7256674' lon='-4.453939
1' />
<node id='13838218' timestamp='2012-12-11T09:07:12Z' uid='55462' user='L├╝beck
' visible='true' version='9' changeset='14235784' lat='36.7418166' lon='-4.44582
27' />
<node id='13838246' timestamp='2012-02-12T18:13:28Z' uid='55462' user='L├╝beck
' visible='true' version='9' changeset='10666125' lat='36.7394169' lon='-4.45240
97' />
1 2 3 4 5
... open my $dateiHandle, "<", "test.osm" or die $!; while (my $line = <$dateiHandle>) { ... }
1 2 3 4 5 6
# Auslesen der Koordinaten my ($lat_old) = $_ =~ m/lat='[+-]?\d+\.?\d*'/; my ($lon_old) = $_ =~ m/lon='[+-]?\d+\.?\d*'/; if (defined ($lat_old) && defined ($lon_old)){ print "my lat= ".$lat_old." lat= ".$lon_old."\n"; }
Quotemy lat= 1 lat= 1
<node id='13838246' timestamp='2012-02-12T18:13:28Z' uid='55462' user='L├╝beck
' visible='true' version='9' changeset='10666125' lat='36.7394169' lon='-4.45240
97' />
my lat= 1 lat= 1