On 2/12/07, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote:
Hi All,
I need to concatenate specific string for each element in the array. I
tried in the following way with the help of join operator.
foreach (@mail)
{
my $str1=$_;
$str1=$str1 . "@abc.com";
"@abc.com" is an interpolating string, which tries to interpolate the
content of an array variable called @abc into the resulting string.
You must use escaping
"[EMAIL PROTECTED]"
or single quotes (as suggested by Jeff Pang):
'@abc.com'
You may find faster this type of errors if you insist on starting your
Perl scripts with
use strict;
use warnings;
This way a mistake like
$ perl -e '$a = "@abc.com"; print $a'
.com
won't pass unnoticed. "use warnings" makes it complain with useful hint:
$ perl -e 'use warnings; $a = "@abc.com"; print $a'
Possible unintended interpolation of @abc in string at -e line 1.
Name "main::abc" used only once: possible typo at -e line 1.
.com
and "use strict" makes it stop because you never declared an @a
variable in the current scope:
$ perl -e 'use strict; use warnings; $a = "@abc.com"; print $a'
Possible unintended interpolation of @abc in string at -e line 1.
Global symbol "@abc" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.
print "$str1\n";
}
But somehow it is not getting concateneted.
please help.
Regards
Irfan.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/