On or about Wed, Oct 09, 2002 at 11:18:34AM +0100, Martin Bower typed:
>Could anyone suggest a better way to split $text into a hash, using the keys
>stored in @header ?
>Any tips would be appreciated.

>my $text = "first second    Third    fourth    fifth  sixth";
>my @header = ( '1st', '2nd' , '3rd' , '4th' , '5th' , '6th' );

my @fields=split ' ',$text,scalar @header;
my %end_hash=map {$header[$_] => $fields[$_]} 0..$#header;

R

Reply via email to