On Wednesday, August 25, 2004 5:57 PM, loan tran wrote: > So for example here is my file: > 1 5 4 > 1 0 2 > 1 2 2 > 2 0 2 > 3 0 3 > 3 4 6 > And here is the output file I want: > 1 2 2 > 2 0 2 > 3 4 6
not extensively tested: #!/usr/local/bin/perl open(F, "file.txt"); while(<F>){ chop(my $line = $_); my ($key) = $line =~ /^(\d)\s/; $hash{$key} = $line; } close F; foreach my $value (values %hash){ print "$value\n"; } JeremyKister http://jeremy.kister.net/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>