'four' #has four letters in the string 'can\'t' #has five characters and represents "can't" 'hi\there' #has eight characters and represents"hi\\there" (one \ in the string) 'blah\\blah' #has nine characters and represents "blah\\blah" (one \ in the string)If you want to put a new line in a single-quoted string it goes something like this
'line1 line2' #has eleven characters line1, newline character, and then line2Single-quoted strings don't interpret \n as a newline.
$word="hello"; #$word becomes hello $statement="$word world"; #variable interpolation, $statement becomes "hello world" "Hello World\n"; #"Hello World" followed by a newline
| Representation | What it Means |
| \a | Bell |
| \b | Backspace |
| \e | Escape |
| \f | Formfeed |
| \n | Newline |
| \r | Return |
| \t | Tab |
| \\ | Backslash |
| \" | Double quote |
| \007 | octal ascii value this time 007 or the bell |
| \x07 | hex ascii value this time 007 or the bell |
| \cD | any control character.. here it is control-D |
| \l | lowercase next letter |
| \u | uppercase next letter |
| \L | lowercase all letters until \E |
| \U | uppercase all letters until \E |
| \Q | Backslash quote all nonletters and nonnumbers until \E |
| \E | Stop \U \L or \Q |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: String Literals in Perl
by tye (Sage) on Aug 02, 2000 at 19:50 UTC | |
|
Typo in Table - RE: String Literals in Perl
by Anonymous Monk on Nov 04, 2000 at 17:47 UTC | |
by tye (Sage) on May 05, 2001 at 03:17 UTC | |
|
RE: String Literals in Perl
by anguyenperl (Initiate) on Aug 02, 2000 at 07:14 UTC | |
|
Re: String Literals in Perl
by Anonymous Monk on Dec 05, 2001 at 21:34 UTC | |
by Anonymous Monk on Jul 27, 2006 at 08:39 UTC | |
by Hofmator (Curate) on Jul 27, 2006 at 10:50 UTC | |
by tye (Sage) on Jul 27, 2006 at 14:27 UTC |