Sayed, Irfan (Irfan) am Montag, 12. Februar 2007 17:05: > 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.
Hi Irfan, you already got hints about the error and the two famous 'use' lines that make life much easier :-) > foreach (@mail) { > my $str1=$_; > $str1=$str1 . "@abc.com"; > print "$str1\n"; > } The $str1 variable in the above code is not necessary. A shorter way would be: foreach (@mail) { print $_, '@dom.tld', "\n"; } or even: print $_, '@dom.tld', "\n" for @mail; You can also use map (perldoc -f map) for your task. Map is very useful and you may want to get used at it, since it allows compact statements that are nonetheless easy to understand: #!/usr/bin/perl use strict; use warnings; my $domain = '@domain.tld'; # single quotes my @usernames = qw/a b c/; print join "\n", map "$_$domain", @usernames; # some other variants: # print join "\n", map $_.$domain, @usernames; # print join "\n", map {$_.$domain} @usernames; # my @addrs =map "$_$domain", @usernames; __END__ Dani -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/