By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,124 Members | 1,567 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,124 IT Pros & Developers. It's quick & easy.

20050110: string join, substring, length

P: n/a
# strings can be joined by +.
print "this" + " that"

# string can be multiplied
print "this" *5

# substring extraction is done by appending a bracket
# with begin and ending index
a="this and that"
print a[3:6]

# index can be negative,
# and sometimes out of bound will just mean length of the string
print a[3:-2]

# length of the string is len()
print len(a)


# in perl, string join is done with a dot.
$astr= "this" . "that";

# string repeatition is done with an x
print $astr x 5;

# string extraction is done with substr()
# for more about sbstr(), see verbose
# perldoc -tf substr

# length of string is length();
print length $astr;

Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Xah Lee wrote:
# perldoc -tf substr

Is there a specific reason why you are 'ugly-printing' the doc pages?
From 'perldoc perldoc':

-t text output
Display docs using plain text converter, instead of nroff. This may
be faster, but it won't look as nice.

Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.