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

{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}'.

Replies are listed 'Best First'.
Re^9: Read the lines until a string exists in the array
by rovf (Priest) on Aug 17, 2009 at 07:13 UTC

    To catenate to variables $v and $w, you write something like

    my $catenated=$v.$w
    In your case, you more likely want to append a variable (for example, a new author which you find on a new line), to an existing variable (for example, the variable containing the authors you already have encountered so far). In this case, you use the .= operator:
    my $string_of_authors .= $next_author;
    One note on the side: May I ask you whether you have had already done any programming in whatever language before starting this project? Definitely no offense intended, but I get the impression that your primary problem is not so much related to Perl, but to programming as such, and if this is the case, you should say so; because in that case, we should approach the problem in general, by first discussing what algorithm to use in order to solve the problem (exressing the algorithm in high-level pseudo-code), and only THEN go ahead and translate it to Perl...

    -- 
    Ronald Fischer <ynnor@mm.st>