in reply to Any hints on how to do this?

Provided the names are grouped together, you could save the name in a variable and check the name in the next line. If it equals the saved name, just print some spaces, otherwise print the name.

There, did that solve your homework? ;-)

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re^2: Any hints on how to do this?
by Anonymous Monk on Jul 25, 2006 at 21:42 UTC
    Hi CountZero, thanks for your time... That was exactly what I was thinking of doing, but I don't seem to be getting anywhere.. Do I need an array or just check the name in the following line, perhaps using the <> to move to the following line and do my pattern matching again?
      No need to use an array:
      use strict; my ($saved_name, $number) = split /\s/, <DATA>; print "$saved_name\t$number\n"; while (<DATA>) { (my $name, $number) = split /\s+/, $_; if ($saved_name eq $name) { print ' '; } else { print $name; } print "\t$number\n"; $saved_name=$name; } __DATA__ GEORGE 21 GEORGE 45 NICK 12 PETER 27 JIM 18 JIM 87 CHRIS 33
      Output:
      GEORGE 21 45 NICK 12 PETER 27 JIM 18 87 CHRIS 33

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law