Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate one string to another?

Status
Not open for further replies.

sdslrn123

Technical User
Jan 17, 2006
78
GB
This is related to the following thread but I was told once before that if I have a new query, I should put it in a new thread.


I believe I can solve the problem originally posted in the thread above if anyone has any ideas on how I can concatenate two strings from a data file as follows

ST
YZ1
YZ2

I want to convert it to
ST
YZ1YZ2

Any ideas? Thanks.
 
Don't know if I read the question correctly, but you can concatenate strings by using the '.' operator.

my $YZ1YZ2 = $YZ1 . $YZ2;

? ? ?

 
Or, if you're looking for strings that match the beginning characters, something like the following pseudo code should work...

Code:
use strict;

while (<DATA>) {
  if (=~ m/^YZ/) {
    $yz .= $_;
  }
  else {
    #do something else
  }
}

__DATA__
ST
YZ1
YZ2

- George
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top