Leser: 1
10 Einträge, 1 Seite |
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
#!/usr/bin/perl while(<>) { @stuff=split(' '); if(/UQMD/){ } elsif(/projectile:/){ $protar=$_ } elsif(/equation_of_state:/){ $ecm=$stuff[5]; $elab=$stuff[3]; $plab=$stuff[7]; } elsif(/event#/){ $noe++ # numbers of events: noe } else{ if($#stuff==14||$#stuff==13){ @x=@stuff[0..3]; @p=@stuff[4..7]; @id=@stuff[8..11]; $mass=$id[0]; $ityp=$id[1]; $iz2=$id[2]; $charge=$id[3]; # ab hier steht folgende info zur verfuegung: # stuff[0] = r_0 = $x[0] # stuff[1] = r_x = $x[1] # stuff[2] = r_y . # stuff[3] = r_z . # stuff[4] = p_0 = $p[0] # stuff[5] = p_x = $p[1] # stuff[6] = p_y . # stuff[7] = p_z . # stuff[8] = mass = $id[0] # stuff[9] = ityp = $id[1] # stuff[10]= iz2 = $id[2] # stuff[11]= charge = $id[3] # hier bestimm ich was ich suche if ($ityp==1){ open(file, ">sort.txt"); print file ("! ",$protar); print file ("!number/event:",$number/$noe," ,ev:",$noe,"\n"); foreach $i(0 .. $#n){ print file ($x[0],"",$x[1],"",$x[2],"",$x[3],"",$p[0],"",$p[1],"",$p[2],"",$p[3],"",$id[0],"",$id[1],"", $id[2],"", $id[3],"\n") } close(file);
Quote\n\ntimo@timo-lnx:~/perl$ perl id_sort.pl test.f14
syntax error at id_sort.pl line 60, near ")
print"
Execution of id_sort.pl aborted due to compilation errors.
timo@timo-lnx:~/perl$
(.*\d\.\d+\w\+0\d)
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
#!/usr/bin/perl # y % mean p_x (y) $dy=.1; while(<>) { @stuff=split(' '); if(/UQMD/){ } elsif(/projectile:/){ $protar=$_ } elsif(/equation_of_state:/){ $ecm=$stuff[5]; $elab=$stuff[3]; $plab=$stuff[7]; } elsif(/event#/){ $noe++ &nbs p; # numbers of events: noe } else{ if($#stuff==14||$#stuff==13){ @x=@stuff[0..3]; @p=@stuff[4..7]; @id=@stuff[8..11]; $mass=$id[0]; $ityp=$id[1]; $iz2=$id[2]; $charge=$id[3]; # ab hier steht folgende info zur verfuegung: # stuff[0] = r_0 = $x[0] # stuff[1] = r_x = $x[1] # stuff[2] = r_y . # stuff[3] = r_z . # stuff[4] = p_0 = $p[0] # stuff[5] = p_x = $p[1] # stuff[6] = p_y . # stuff[7] = p_z . # stuff[8] = mass = $id[0] # stuff[9] = ityp = $id[1] # stuff[10]= iz2 = $id[2] # stuff[11]= charge = $id[3] if ($id[1]== 40){ #if ($ityp== 40 ){ # if ($ityp==1 && $charge==1){ $number++; $pp=sqrt($p[1]*$p[1]+$p[2]*$p[2]+$p[3]*$p[3]); $y=0.5*log(($pp+$p[3])/($pp-$p[3])); $ymin=-4.05; $iy=int(($y-$ymin)/$dy); $n[$iy]++; $symfac=1; if ($sym==1){ $symfac=2; $number++; $y=-0.5*log(($p[0]+$p[3])/($p[0]-$p[3])); $ymin=-20; $iy=int(($y-$ymin)/$dy); $n[$iy]++; } } } } } $midy=0; open(file, ">ausgabe.txt"); print file ("! ",$protar); print file ("!number/event:",$number/$noe," ,ev:",$noe,"\n"); print file ("\n"); print file ("r_0"," ","r_x"," ","r_y"," ","r_z"," ","p_0"," ","p_x"," ","p_y"," ","p_z"," ","mass"," ","ityp"," ","iz2"," ","charge"," \n"); foreach $i(0 .. $#n){ print file ($x[0]," ",$x[1]," ",$x[2]," ",$x[3]," ",$p[0]," ",$p[1]," ",$p[2]," ",$p[3]," ",$id[0]," ",$id[1]," ",$id[2]," ",$id[3],"\n") } close (file);
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl # das ganze muss NATUERLICH noch entsprechend angepasst werden use warnings; use strict; use diagnostics; my $content = " crap crap crap 0.20000000E+04 -0.43339133E+02 -0.83744754E+02 0.19753227E+04 0.63633301E+01 -0.13903707E+00 -0.27834355E+00 0.62861212E+01 0.93800002E+00 1 1 1 1 6 20 blalblah "; my $regex = '(.*\d\.\d+\w\+0\d\s\d*\s\d\s\d\s\d\s\d\s\d+)'; my ($tmp1) = $content =~ /$regex/m; my @foo = split(/\s/, $tmp1); foreach (@foo) { print; print "\n"; }
Quotejo also ich muss gestehn ich versteh deinen code garnich, liegt wohl auch daran dass ich erst seit 2 tagen überhaupt mit perl hantiere ^^
Quoteansonsten ist es so die spalten sind ab dem zeitpunkt wenn der kopf vorbei ist immer gleich also nur solche zahlen spallten... allerdings ist es so dass ich mit den werten aus bestimmten spalten wenn mir der ityp true liefert auch rechnen will, also einerseits will ich nur bestimmte zeilen erst mal auslesen und in eine neue datei schreiben und im 2. schritt dann mit den werten der spalten rechnen, hoffe ich habs verständlich ausgedrückt
0.20000000E+04 -0.36313144E+03 0.98361995E+02 0.19077208E+04 0.50967221E+01 -0.93159359E+00 0.25738263E+00 0.48602057E+01 0.11920000E+01 40 0 0 12 7 20
Quoteallerdings ist es so dass ich mit den werten aus bestimmten spalten wenn mir der ityp true liefert auch rechnen will
10 Einträge, 1 Seite |