Dr.Avocado has asked for the wisdom of the Perl Monks concerning the following question:
I've been searching column "Name" for the values I want and using those rows by usingScore | Points | Time | Points | Record | Size | Points | Age | Points + | Difficulty | Size | Points | Name 4 |15 |356 |17 |45 |14 |45 |24 |12 + |3 |1 |34 |team A 6 |24 |354 |45 |345 |53 |25 |47 |34 + |3 |3 |45 |team B 3 |18 |303 |34 |234 |32 |48 |67 |32 + |23 |4 |22 |team C 7 |13 |322 |26 |33 |56 |57 |46 |23 + |3 |1 |14 |team D 5 |10 |353 |24 |58 |82 |35 |33 |12 + |5 |2 |35 |team E 5 |30 |264 |48 |26 |23 |23 |73 |23 + |5 |2 |65 |team F 6 |18 |363 |58* |39 |71 |35 |75 |46 + |2 |4 |23* |team_triumph ---------------------------------------------------------------------- +------------------------------------- x |x |x |x |x |x |x |x |x + |x |x |x |Total ---------------------------------------------------------------------- +------------------------------------- Score | Points | Time | Points | Record | Size | Points | Age | Points + | Difficulty | Size | Points | Name 2 |32 |443 |34 |464 |38 |89 |9 |43 + |3 |4 |353 |Team C 5 |24 |343 |543 |923 |478 |0 |35 |3 + |3 |2 |39 |Team B 6 |5 |263 |232 |92 |43 |48 |96 |46 + |4 |52 |78 |team_victory ---------------------------------------------------------------------- +------------------------------------- x |x |x |x |x |x |x |x |x + |x |x |x |Total ---------------------------------------------------------------------- +------------------------------------- Score | Points | Time | Points | Record | Size | Points | Age | Points + | Difficulty | Size | Points | Name 5 |76 |366 |37 |593 |453 |34 |68 |65 + |35 |4 |54 |Team D 3 |34 |235 |102 |967 |290 |2 |54 |2 + |3 |6 |3 |Team C 2 |643 |643 |34 |291 |10 |2 |43 |53 + |3 |7 |46 |Team F 5 |43 |362 |2 |152 |35 |35 |24 |5 + |2 |43 |7 |Team G 6 |7 |643 |6* |45 |0 |97 |75 |883 + |1 |2 |344* |team_intrepid ---------------------------------------------------------------------- +------------------------------------- x |x |x |x |x |x |x |x |x + |x |x |x |Total ---------------------------------------------------------------------- +-------------------------------------
#!/usr/local/bin/perl open(my $fh, "<", "data.txt") || die "Can't open file: $!"; # Run through all lines of the file, one by one while(my $line = <$fh>) { # Break up the line on whitespace, assign columns to vars my( $score,$scorePoints, $time,$timePoints, $record,$recordPoints, $size,$sizePoints, $age,$agePoints, $diff,$diffPoints, $size2,$size2Points, $name ) = split(/\s+/,$line,13); # Check to see if name matches if($name =~ /(intrepid|triumph)/) { print "$name\n", "Time: $timePoints, Difficulty: $diffPoints\n\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching for Numerous Values
by moritz (Cardinal) on Aug 01, 2007 at 17:16 UTC | |
|
Re: Searching for Numerous Values
by bkchapin (Acolyte) on Aug 01, 2007 at 19:51 UTC | |
|
Re: Searching for Numerous Values
by ikegami (Patriarch) on Aug 01, 2007 at 17:02 UTC | |
by ikegami (Patriarch) on Aug 01, 2007 at 17:06 UTC |