Leser: 24
Quoten => node
w => way
r => relation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
sub splitTypeId { my $argument = shift ; my $type = ""; if ($argument =~ /^n/){ $type = "node"; }elsif ($argument =~ /^w/){ $type = "node"; }else{ $type = "relation"; } my $id = substr($argument,1); my $result = $type.";".$id; return $result; }
my($poi_type, $purge_id) = split( /;/, splitTypeId($unnamed_id), 2 );
my( $type, $id ) = $argument =~ /(\w)(\d+)/;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
sub splitTypeId { my ($arg) = @_; my ($type,$id) = m/ \A (\w) (\d+) \z /x; my %map = ( n => 'node', w => 'way', r => 'relation', ); $type = $map{$type} || ''; return ($type, $id); }
my($poi_type, $purge_id) = splitTypeId($unnamed_id);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
use Carp qw(croak); # use namespace::clean; # <-- Das nur wenn du ein OOP Modul hast sub splitTypeId { my ( $arg ) = @_; my ( $type, $id ) = $arg =~ m/ \A (\w) (\d+) \z /xms; my %map = ( n => 'node', w => 'way', r => 'relation', ); $type = $map{$type} || croak "Invalid Type ($type) is ($arg) a correct string for splitTypeId() ?\n"; return $type, $id; }
my ( $type, $nmr ) = unpack 'A A*', $arg;
state %map = ( ... );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
sub splitTypeId { my ( $arg ) = @_; my ( $type, $id ); if ( $arg =~ m/ \A (\w) (\d+) \z /xms ) { $type = $1; $id = $2; } else { croak "Invalid format ($arg)\n"; } state %map = ( n => 'node', w => 'way', r => 'relation', ); if ( !exists $map{$type} ) { croak "Type ($type) is invalid\n"; } return $map{$type}, $id; }