Perl 101 (Part 2) - Of Variables And Operators - ... Or Two Plus Two (Page 4 of 8 )
Of course, operators are not restricted to numbers alone - there are a couple of useful string operators as well. The string concatenation operator [.] is used to concatenate strings together, as in the following example:
#!/usr/bin/perl
$a = "The";
$b = "Incredible";
$c = "Shrinking";
$d = "Violet";
$result = $a . $b . $c . $d;
print "Here's one possibility - $result\n";
$result = $c . $a . $b . $d;
print "And here's another - $result\n";
And the string repetition operator[x] is used to repeat
strings a specific number of times - take a look:
#!/usr/bin/perl
$a = "Loser!\n";
$insult = $a x 7;
print($insult);
Talk about using your powers for evil...
This article copyright Melonfire 2000. All rights reserved.Next: Comparing Apples And Oranges >>
More Perl Articles
More By Vikram Vaswani and Harish Kamath, (c) Melonfire