$_ .= 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. | [reply] [d/l] [select] |
{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}'.
| [reply] [d/l] |
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>
| [reply] [d/l] [select] |