Thread Stings vergleichen (11 answers)
Opened by Rennofen at 2017-10-12 22:23

Rennofen
 2017-10-13 11:45
#187510 #187510
User since
2017-10-12
6 Artikel
BenutzerIn
[default_avatar]
bisher habe ich folgendes:

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
23
24
25
26
27
28
29
30
31
#!/bin/perl
use strict;
use warnings;
 
my $filename = '808.nc';
open(my $fh, '<:encoding(UTF-8)', $filename)
  or die "Could not open file '$filename' $!";
my $g="G";
my $f="F";
while (my $row = <$fh>) {
  chomp $row;
  my @words = split / /, $row;
    foreach (@words){
    my $Word=$_;
    my $char=substr($_, 0, 1);
     if ($char eq "G"){
      if($Word ne $g){
      $g=$Word;
      print "$Word "
      }
     }    
     elsif ($char eq "F"){
      if($Word ne $f){
      $f=$Word;
      print "$Word "
      }
     }    
     else {print "$Word "}
    }
  print "\n";
}


das macht aber nicht so richtig was es soll..

ab und an fehlt der erste Buchstabe einer Zeile

Beispiel.

aus:

Code: (dl )
1
2
3
4
5
6
7
8
9
N46 G1 X13 Y-18 Z-2 F2328
N48 G3 Z0 X15 Y-18 I0 K2 F2328
N49 G0 X15 Y-18 Z15
N51 (Planen2)
N52 G0 X10.102 Y-25.75
N53 G0 X10.102 Y-25.75 Z15
N54 G0 X10.102 Y-25.75 Z5
N55 G1 X10.102 Y-25.75 Z1 F2328
N57 G2 Z-1 X8.102 Y-25.75 I-2 K0 F2328


mach das script:

Code: (dl )
1
2
3
4
5
6
7
8
9
N46 G1 X13 Y-18 Z-2 F2328
N48 G3 Z0 X15 Y-18 I0 K2
49 G0 X15 Y-18 Z15
51 (Planen2)
52 X10.102 Y-25.75
53 X10.102 Y-25.75 Z15
54 X10.102 Y-25.75 Z5
N55 G1 X10.102 Y-25.75 Z1
N57 G2 Z-1 X8.102 Y-25.75 I-2 K0


bin wie gesagt ziemlich eingerostet...

View full thread Stings vergleichen