my %hash; while ( ) { my ( $key ) = ( m/^(\w+)/ ) or next; $hash{$key} = 'whatever'; } #### my %hash; while ( ) { my ( $key, $value ) = split /\|/, $_, 2; next unless $key; $hash{$key} = $value; } #### /^(\w+)\|/; $hash{$1)='blah'; #### if ( /^(\w+)\|/ ) { $hash{$1} = 'blah' }