in reply to simply appending to a scalar...
There are seven ways I can immediately think of, and you've picked one of the clearest and easiest. Here is the list I can come up with:
- The . (dot) operator: concatenation.
- The .= operator: append.
- substr: Substring manipulation.
- join: Joining two or more strings.
- s/(...)/$1$string/: Substitution.
- The qq/...../ or "...." operator: interpolation.
- open: open my $fh, '>+', \$variable or die $!;: Print to an in-memory filehandle.
I'm sure I've missed a few, but these ways jump to mind immediately. The last method I listed; open, is pretty obfuscatory in nature. There aren't many situations I can think of where it would be a favorable approach, especially if simple concatenation is your goal. But it's there, so I mentioned it.
dot (.) and dot-equals (.=) are definitely the simplest and clearest approaches.
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: simply appending to a scalar...
by ikegami (Patriarch) on Jun 28, 2006 at 05:10 UTC | |
Re^2: simply appending to a scalar...
by abachus (Monk) on Jun 27, 2006 at 23:53 UTC | |
by davido (Cardinal) on Jun 28, 2006 at 04:00 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 04:48 UTC | |
by abachus (Monk) on Jun 28, 2006 at 13:00 UTC | |
by ikegami (Patriarch) on Jun 28, 2006 at 14:01 UTC |
In Section
Seekers of Perl Wisdom