in reply to How to combine string and digits in perl
The concatenation operator (dot), described in perlop, is not intended to be used inside a string. It is expected to join strings. So the following work:
"foo" . '_' . 123 $abc . '_' . 123 "foo" . '_' . $num
But the following do not work, because dot inside a string is just a dot, not an operator:
"$abc . _ . 123" "foo . _ . $num"
What you want is one of the following:
"${abc}_$_" # 1 $abc . '_' . $_ # 2 join('_', $abc, $_) # 3 "$abc\_.$_" # 4 $abc . "_$_" # 5
I prefer option 1, 2 or 3. Option 2 is probably the most legible.
Perl would probably make a lot more sense if you read perlintro, perlsyn, perlop, perlsub, and perldata. That's a couple hours worth of material, but it would move you forward in your learning curve.
In perlop you can also read The Gory Details of Parsing Quote and Quote-like Constructs.
Dave
|
|---|