AgentM had pretty much the complete list (except
chop). Your question, however, is
not really specific enough to do more then point you at these documents. But I suspect,
rather... HOPE, that you looked at the
library before posting your question and have
therefor seen these documents (
chop,
chomp,
tr,
s) so you probably wanted an example.
Lets see:
use strict; #Always!
my $string = "This is a test string. 123\n";
chomp($string); # removes the "\n" from the end of $string.
chomp($string); # no-op. chomp only removes white-space: \t, ' ', \n,
+etc...
chop($string); # removes the '3' from the end of $string.
chop($string); # removes the '2'... get the idea?
print $string, $/; # print the string, and a new-line.
$string =~ s/a //; # replaces an appearance of 'a ' with ''
print $string, $/; # print the string, and a new-line.
# should read: "This is test string. 1"
$string =~ tr/.//d; # remove all periods.
print $string, $/;
$string =~ s/.$//; # removes the last char. slower then chop.
$string =~ s/..$//; # removes the last two characters.
my $n = 6;
$string =~ s/.{$n}$//; # removes the last $n characters.
print $string, $/;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.