Strings
Double quotes (") or single quotes (')!"Hello\nThere\n" ## string value, with newlines in it
'Hello' – Or use single quotes, but then \n's and interpolation are suppressed.
Concat with period (.)
$str = $z . " twice " . $z; ## concat
Interpolation
Variables are evaluated and pasted into a quoted string...
$x = 42;
$str = "The answer is $x, so there!\n"; ## the "42" gets pasted in
String comparison
("hello" eq $str) ## case sensitive string equals test
("hello" ne $str) ## case sensitive string not equals test
Do not use the == comparison with strings, == is for numbers
lc(), uc() ## upper/lower case fns
No comments:
Post a Comment