azsoft
asked on
Declare a long string using $
Hi,
I'm new in Perl. I've an assignment to edit perl script.
This is the original line
my $MAILRCP = 'john,anna,steven';
If I have a very long string(additional name to add on) , can I do like this:
my $MAILRCP = 'john,anna,steven,garry,to m,Jeff',
'alia','mike','guna','larr y';
Please help.
Thanks
I'm new in Perl. I've an assignment to edit perl script.
This is the original line
my $MAILRCP = 'john,anna,steven';
If I have a very long string(additional name to add on) , can I do like this:
my $MAILRCP = 'john,anna,steven,garry,to
'alia','mike','guna','larr
Please help.
Thanks
to append to the end of a string you use the concatenation operator '.=' but it all depends on the structure of the data you are adding. If the string to add is already formatted exactly how you need it:
$foo = 'this';
$bar = 'that';
$foo .= $bar;
print $foo;
as ozo showed above there are numerous ways to append data to a string.
$foo = 'this';
$bar = 'that';
$foo .= $bar;
print $foo;
as ozo showed above there are numerous ways to append data to a string.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>If I have a very long string(additional name to add on) , can I do like this:
if you have a number of additional names to add on from some source say from a file its
better to loop and process one record at a time.
putting all the names in one var will take lots of memory.
my $MAILRCP = 'john,anna,steven,garry,to
'alia'.'mike'.'guna'.'larr
or like this:
my $MAILRCP = 'john,anna,steven,garry,to
alia,mike,guna,larry';
or like
my $MAILRCP = join",",'john,anna,steven,
'alia','mike','guna','larr
Depending on what you want the string to contain