#StoneProfitsSystem


Strings and Parser Method

String Literals:

  • String Literals are groups of characters surrounded by quotes so that they can be used as a single datum. 
  • They are frequently used in programs to identify filenames, display messages, and prompt for input. In Perl you can use single quotes ('), double quotes("), and back quotes (`).

Example: Single-Quoted Strings

  • A single-quoted string is pretty simple. Just surround the text that you'd like to use with single quotes.
 E.g. 'David Marshall'

  • The single-quotes are used here specifically so that the double-quotes can be used to surround the spoken words.
  •  Later in the section on double-quoted literals, you'll see that the single-quotes can be replaced by double-quotes if you'd like. You must know only one more thing about single-quoted strings. 

Example: Double-Quoted Strings
  • The basic double-quoted string is a series of characters surrounded by double quotes. If you need to use the double quote inside the string, you can use the backslash character.
  • This literal is similar to one you've already seen. Just the quotes are different. 
Another literal that uses double quotes inside a double-quoted string: "David said, \"It is fun to learn Perl.\""

Parser:
  • Perl has a rightful reputation as a good language for parsing text and even its name originally stands for "Practical Extraction and Report Language".
Example:



Output is here:

No comments:

Post a Comment