Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > how to concat two strings into one?

Reply
Thread Tools

how to concat two strings into one?

 
 
mozilla.bugzilla@gmail.com
Guest
Posts: n/a
 
      07-09-2005
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

 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      07-09-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:

> 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--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
 
 
 
mozilla.bugzilla@gmail.com
Guest
Posts: n/a
 
      07-09-2005
Thank you so much,sherm! It works.


bugzilla

 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      07-09-2005
(E-Mail Removed) wrote:
> 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


 
Reply With Quote
 
Brandon
Guest
Posts: n/a
 
      07-09-2005
hi,

It woudl be something like:

print $stringA . $stringB;

You use the "." operator.

Brandon

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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
>



 
Reply With Quote
 
Joe Smith
Guest
Posts: n/a
 
      07-10-2005
(E-Mail Removed) wrote:
> 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
 
Reply With Quote
 
Anno Siegel
Guest
Posts: n/a
 
      07-11-2005
Jürgen Exner <(E-Mail Removed)> wrote in comp.lang.perl.misc:
> (E-Mail Removed) wrote:
> > 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.


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

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
RAILS: edit turns null strings into empty strings Wybo Dekker Ruby 1 07-23-2005 05:30 PM
EL: concat strings Timo Nentwig Java 4 05-08-2004 05:28 PM
dropdownlist-concat two fields-can it be done ctb ASP .Net 2 07-18-2003 04:20 PM



Advertisments