Henrik Nielsen schreef:

> I need to write a program that search a CDR file for duplicate lines
> and then delete them.
> [...]
> while ( <$in> ) {
>       my $key = join ',', ( split /,/ )[ 2, 3, 6, 7 ];
>       print $out $_ unless $hash{ $key }++;
>       }
> [...]
> ---------------
> This program should take out the cells 2, 3, 6 and 7 in a file split
> by comma. My CDR file is split by space.

For SP separators specifically, use:

       my $key = join ' ', ( split / +/)[ 2, 3, 6, 7 ];


Often this is better:

       my $key = join ' ', ( split ' ')[ 2, 3, 6, 7 ];


(a ' ' with split works almost like /\s+/, see `perldoc -f split` about
the details)


> How can I use 'readline EXPR'?

The "<$in>" is a readline().

-- 
Affijn, Ruud

"Gewoon is een tijger."


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to