Nano's Blog

01/05/2010

String Operators

Filed under: programming — Tags: — nano @ 07:56

. operator
a single period. String values can be concatenated with the operator.

x operator
a single lowercase letter x. A special repetition operator.

- from Learning Perl 5E

Sampe Code

#!C:\Perl\bin\perl.exe
use strict;
use warnings;

print "hello" . "world\n";       # same as "helloworld"
print "hello" . ' ' . "world\n"; # same as 'hello world'
print 'hello world' . "\n";    # same as "hello world\n"
print "\n";

print "4 x 5";
print "\n";
print '4 x 5';
print "\n";
print "4" x 5;
print "\n";
print 4 x 5;

print "\n\n";
my $i = 4 * 5;
print $i;

Output

helloworld
hello world
hello world

4 x 5
4 x 5
44444
44444

20

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress