Try this: #!/usr/bin/perl
use strict; my $file=$ARGV[0]; open(FH,"$file") || die "can not open file named $file for reading\n"; #Init stuff my $current_line=<FH>; my ($from,$prev_key)=split /\s+/,$current_line; my $prev_to=$from; #Go while($current_line=<FH>){ my ($current_to,$current_key)=split /\s+/,$current_line; if($current_key ne $prev_key){ print "from $from to $prev_to $prev_key\n"; $prev_key=$current_key; $from=$current_to; }; $prev_to=$current_to; } close(FH); #in case of the file contains just one line. print "from $from to $prev_to $prev_key\n"; __END__; José. > -----Original Message----- > From: Pedro Antonio Reche [mailto:reche@;research.dfci.harvard.edu] > Sent: Thursday, October 31, 2002 6:18 PM > To: [EMAIL PROTECTED] > Subject: parsing two column file > > > Hi all, I have been struggling with the following problem. I > have a file that looks as it follows: > > #### > 5 . > 6 . > 7 H > 8 H > 9 H > 10 E > 11 E > 12 . > 13 . > > and I want to write something like this: > > from 5 to 6 . > from 7 to 9 H > from 10 to 11 E > from 12 to 13 . > > Any help welcome. > Cheers > -- > ******************************************************************* > PEDRO A. RECHE , pHD TL: 617 632 3824 > Dana-Farber Cancer Institute, FX: 617 632 4569 > Harvard Medical School, EM: > [EMAIL PROTECTED] > 44 Binney Street, D1510A, EM: [EMAIL PROTECTED] > Boston, MA 02115 URL: http://www.reche.org > > ******************************************************************* > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > **** DISCLAIMER **** "This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer". Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]