CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
join or concatenating a string

 



spc1to3
New User

Aug 8, 2012, 8:24 PM

Post #1 of 3 (728 views)
join or concatenating a string Can't Post

I would like to join a specific string with numbers:
My data:
LC 4
..... LC 23120
...LC 53347
etc. My data is more complex than that with other words before and after the list above.
So I wrote:
#!/usr/bin/perl
$string = join( "", "LC ", "4" );
Print "Joined String is $string\n";
and the result is:
Joined String is LC 4
Instead of Joined String is LC4

How can I remove the white space between LC and numbers so it would look like this: LC53347 ?

Thank you. [:/]


Laurent_R
Enthusiast / Moderator

Aug 8, 2012, 11:20 PM

Post #2 of 3 (723 views)
Re: [spc1to3] join or concatenating a string [In reply to] Can't Post

Something like this:

my ($field1, $field2) = split " ", $start_string;

my $end_string = "$field1$field2\n"


Laurent_R
Enthusiast / Moderator

Aug 9, 2012, 10:57 AM

Post #3 of 3 (715 views)
Re: [spc1to3] join or concatenating a string [In reply to] Can't Post

You have a space after the LC in:


Code
$string = join( "", "LC ", "4" );


That's why you end up with "LC 4" instead of "LC4".

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives