in reply to Re^2: Parsing problem
in thread Parsing problem
This code should get you started.
use strict; use warnings; my @list = split /\n/, <<BLOCK1; 1 2 - perlmonks1 sdweq23 3 4 - javaforums2 sd341 5 6 - dreamtech3 fr4frf34 6.5 6.6 - dreamtech3 fr4frf34 7 8 + dreamtech3 dcvdf3443 9 10 + sunforum4 sdcds3443 11 12 - sunforum4 ddfvdv333 BLOCK1 my ($oldname1,$oldname2) =("") x 2; my ($buf, $occurrances)=(0,0); my ($max,$min); for (@list,""){ my ($num1,$num2,$sign,$name1, $name2) = split; if ($name1 && $name1 eq $oldname1){ $occurrances++ ==1 and $buf .= " start"; }else{ if ($occurrances > 1){ $buf .= " end"; }elsif ($occurrances ==1){ $buf .= " one"; } $occurrances = 1; } (! defined $max) || ($num1 && $num1 > $max ) and $max = $num1; (! defined $min) || ($num1 && $num1 < $min) and $min=$num1 ; print "$buf\n" if $buf; $buf = $_; $oldname1=$name1; } print "Min=$min; Max=$max\n";
Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)
|
|---|