Thread Parameter umwandeln (55 answers)
Opened by Benji2010 at 2010-12-13 12:04

topeg
 2010-12-20 14:32
#143736 #143736
User since
2006-07-10
2611 articles
BenutzerIn

user image
In Zeile 13 einen "." zu den erlaubten Zeichen hinzuf├╝gen:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl -p

use strict;
use warnings;
use vars qw(%var);

while ( /([A-Z][0-9]*)=(\S+)/g ) {
    my( $id, $val, $pos ) = ( $1, $2, pos );
    my $len = length $val;
    
    (my $tmp_val = $val) =~ s/([A-Z][0-9]*)/$var{$1}||''/ge;
    
    if ( $tmp_val =~ /^[\d\*\/\+\-\(\).]+$/ ) {
        $tmp_val = eval $tmp_val;
        $var{$id} = $val = $tmp_val unless $@;
    }
    
    substr $_, $pos - $len, $len, $val;
    pos = $pos - $len + length $val;
}

View full thread Parameter umwandeln