Time to re-examine strings. From an earlier tutorial page, its been noted that a string is simply a piece of data that contains letters and may contain numbers as well. Basically though, it is a non-fully-numeric piece of data. This page will show some different abilities you can do with strings.
Connecting or combining strings. JavaScript uses the + (plus) symbol to connect strings. Perl uses the . (period) symbol.
$fullname1 has the value of "JohnSmith". The script literally combined the two scalar variables together. The second combining script line shows how to put a space in there. $fullname2 has the value of "John Smith".
Strings can have a repetition operator. That is the one string may be repeated (copied and combined) onto itself.
The $result will contain the value "DaveDaveDaveDave"
Case operators control the CaSe LeTtErInG.
See it in action!
Connecting or combining strings. JavaScript uses the + (plus) symbol to connect strings. Perl uses the . (period) symbol.
|
$firstname = "John"; $lastname = "Smith"; $fullname1 = $firstname . $lastname; $fullname2 = $firstname . " " . $lastname; |
$fullname1 has the value of "JohnSmith". The script literally combined the two scalar variables together. The second combining script line shows how to put a space in there. $fullname2 has the value of "John Smith".
Strings can have a repetition operator. That is the one string may be repeated (copied and combined) onto itself.
| $result = "Dave" x 4; |
The $result will contain the value "DaveDaveDaveDave"
Case operators control the CaSe LeTtErInG.
| Case Op | Escape Equivalent | Result |
| lc | \L | All letters in the string are converted to lower case. |
| lcfirst | \l | Only the first letter in the string is converted to lowercase. |
| uc | \U | All letters in the string are converted to upper case. |
| ucfirst | \u | Only the first letter in the string id converted to uppercase. |
|
$name1="Jack"; $name2="Jill"; $newname1= lc $name1; $newname2= uc $name2; print "name1 is $name1. <br>"; print "name2 is $name2. <br>"; print "newname1 is $newname1. <br>"; print "newname2 is $newname2."; |

