.:: Welcome To My Personal Blog ::.

Saturday, March 5, 2011

Beginner's Guide To Travel With Perl - Part 2

Strings

Let’s say something about strings. A string is a group of characters between two single quotes or two double quotes. If the characters are bounded with single quotes, the elements are not interpreted. But if they are bounded with double quotes, it means that the contents should be interpreted.



Example :
Open a new file and write –
print “This will take \ntwo lines to show.”;
print ‘This will take \n one line to show.’;

Save it as string.pl; the output for this code will be
“This will take
two lines to show.This will take \n one line to show.”

Hope everyone could understand the difference. The character sequence ‘\n’ is a newline character when it appears in a string with double quotes, but is only the two characters, backslash (‘\’) and n (‘n’), when it appears in single quotes.
If it is written like this
print “This will take
Two lines”;

The output will also remain like the output of first line of previous example. It will not differ for the single or double quote.
Two other important backslash sequences are ‘\t’ to insert a tab character, and ‘\\’ to insert a backslash into a double-quoted string.

Number

Now, we will see something about number. Numbers are easy; we've already dealt with it. The only thing we need to know is that, we don’t need to insert commas or spaces into numbers in Perl. Always write 10000, not 10,000 or 10 000.

Help Links:

http://www.perl.com/pub/2000/10/begperl1.html
http://perldoc.perl.org/perlintro.html

http://www.perl.org/learn.html
http://learn.perl.org/books.html
http://learn.perl.org/tutorials/
http://www.perl.com/pub/2008/04/23/a-beginners-introduction-to-perl-510.html
http://docstore.mik.ua/orelly/perl2/prog/ch01_05.htm
http://www.tizag.com/perlT/perluserinput.php
http://www.tizag.com/perlT/perlchomp.php

http://perldoc.perl.org/functions/use.html
http://www.well.ox.ac.uk/~johnb/comp/perl/intro.html

http://www.sthomas.net/roberts-perl-tutorial.htm/ch22/use_strict_
http://docstore.mik.ua/orelly/perl/prog3/ch31_19.htm
http://debugger.perl.org/580/perldebtut.html
http://perldoc.perl.org/strict.html


. . . . . To be continued . . . . .

No comments:

Post a Comment

Popular Posts