in reply to Re^4: Read the lines until a string exists in the array
in thread Read the lines until a string exists in the array

For getting this result, I would approach it differently. I would define a hash, %tags, which is initially empty. Whenever you encounter a tag, say AUTHOR, with some content, say 'author1', you have have two cases:
  1. If AUTHOR does not exist yet in your hash, create a new entry with AUTHOR as a key, and 'author1' as a value.
  2. If AUTHOR already exists in your hash, just append to the existing string your new value (separated by a space).

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^6: Read the lines until a string exists in the array
by Anonymous Monk on Aug 14, 2009 at 17:29 UTC
    %hash = map { $_ => 1 } @metadata_tags; $_ .= exists $hash{$1};
    I have created a hash of tags. I have appended the $_ if tag exists in an array. But still it doesnot concatenate
      $_ .= exists $hash{$1};

      This catenates whatever exists $hash{$1} evaluates to to $_. That is, it catenates the stringified version of the boolean which exists returns.

        {AUTHOR} author1 staff1 {HEADLINE} DISPOSABLE DECOR: THE CUTTING EDGE DULLS FAST\ STYLE AT A SPEED USUALLY ASSOCIATED WITH WARDROBE ITEMS.
        Can you please tell me how to concatenate lines between two variables. Here, {AUTHOR} and {HEADLINE} merge lines in to a single line before any start of another'{tagname}'.