foreach my $this_paragraph (@paras) { my @split_para = split(/:/, $this_paragraph); if( $split_para[1] = $KWD ) { print $this_paragraph; } }