how to concat two strings into one?

  • Thread starter mozilla.bugzilla
  • Start date
M

mozilla.bugzilla

hi, greetings,

I am a newer for PERL. I want to concat two strings into one string,
like this,

$stringA='This is ';
$stringB='A concat example!';

I want to $stingC to be this: $stringC="This is A concat example!";

I searched the help, but did not find the right function, Can you guys
help me figure this out?

Thanks

bugzilla
 
S

Sherm Pendley

I am a newer for PERL.

BTW, it's Perl, not PERL.
I want to concat two strings into one string,
like this,

$stringA='This is ';
$stringB='A concat example!';

I want to $stingC to be this: $stringC="This is A concat example!";

I searched the help, but did not find the right function, Can you guys
help me figure this out?

You searched the wrong help - it's an operator, not a function.

The dot . operator is used for string concatenation, like this:

my $stringC = $stringA . $stringB;

Have a look at "perldoc perlop" for details.

sherm--
 
J

Jürgen Exner

I am a newer for PERL. I want to concat two strings into one string,
like this,

$stringA='This is ';
$stringB='A concat example!';

I want to $stingC to be this: $stringC="This is A concat example!";

Some ways to do it:
$stringC = $stringA . $stringB;
$stringC = "$stringA$stringB";
$stringC = join('', ($stringA, $stringB));

I'm sure there are more.

jue
 
B

Brandon

hi,

It woudl be something like:

print $stringA . $stringB;

You use the "." operator.

Brandon
 
J

Joe Smith

I am a newer for PERL. I want to concat two strings into one string...
I searched the help, but did not find the right function...

You should not be searching the help files for this.
You should be reading an "Introduction to Perl" tutorial.

This question and others imply that haven't been introduced
to the basics of Perl. What are you using as a reference?
-Joe
 
A

Anno Siegel

Jürgen Exner said:
Some ways to do it:
$stringC = $stringA . $stringB;
$stringC = "$stringA$stringB";
$stringC = join('', ($stringA, $stringB));

I'm sure there are more.

$stringC = '';
substr( $stringC, length $stringC, 0, $_) for $stringA, $stringB;

Anno
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top