Thread Textdatei - Mathematische Operationen (22 answers)
Opened by Benji10 at 2011-09-07 11:36

payx
 2011-09-07 13:01
#152179 #152179
User since
2006-05-04
564 Artikel
BenutzerIn

user image
Hallo Benji10,

hier noch ein zweiter Ansatz, etwas geradliniger:
Code (perl): (dl )
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;

while (my $txt = <DATA>) {
    chomp($txt);
    next unless my ($term) = ($txt =~ m/.+=(.+)$/);
    my $result = eval($term);
    print "$txt=$result\n";
}

sub POT {
    return $_[0]**2;
}
sub SQRT {
    return sqrt($_[0]);
}

__DATA__
ABC=1+1
Z=SQRT(POT(320)+POT(200))


HTH
Grüße
payx

View full thread Textdatei - Mathematische Operationen