Thread Parameter umwandeln
(55 answers)
Opened by Benji2010 at 2010-12-13 12:04 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; } Aufruf: Code: (dl
)
1 $ perl script.pl input.txt > output.txt MfG Last edited: 2010-12-13 15:33:52 +0100 (CET) perl -E'*==*",s;;%ENV=~m,..$,,$&+42;e,$==f;$"++for+ab..an;@"=qw,u t,,print+chr;sub f{split}say"@{=} me"'
|