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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Max String Length

Status
Not open for further replies.
Apr 30, 2003
56
US
Does anyone know if there is a maximum length allowed for string in perl language? I am kind of new to this. I am trying to do string manipulation. My total string length now is 473. I am still trying to add 6 position to the end of the string. But it won't let me do it. Could some one help me out here? Thanks a lot!
 
A string can eat up all available memory (I have done it), what exactally are you trying to do, and what is your code?
 
Well, I have one string $string1 that is 473 positions long, and I have another string $string2 that is 6 positions long. I am trying to add the second string to the end of the first string so what I did is I used string concatnation operator $newstring=$string1.$string2; However, no matter what I do, it won't put those 6 position I wanted at the end of 473th position of the first string. It always put it at around position 440. This makes me wonder if there is a maximum string length allowance. Does anyone have any idea?
 
As you can see, this works:

Code:
$string1="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
$string2="123456";
$newstring=$string1.$string2;
print "String 1 length: " . length($string1) . "\n";
print "String 2 length: " . length($string2) . "\n";
print "New string length: " . length($newstring) . "\n";
print "New string: " . $newstring . "\n";
 
$string1 = "one";
$string2 = "two";
$string1 = $string1.$string2;
print $string1;


Kind Regards
Duncan
 
$string1 = "1234567890";
$string2 = "ABC";
$pos = 5;

$string1 = substr($string1,0,$pos) . $string2 . substr ($string1, $pos, length($string1)-$pos, $string2);

print $string1."\n";


Kind Regards
Duncan
 
Thanks for your input. I finally got it to work. But some how I got it to work with the join function to join a space with it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top