So currently at school I'm taking a Scripting in Perl class, and I'm in absolute LOVE with this language. It's easy to understand, has very good English-like syntax, simple array and hash usage, built in BASH support (for all you Linux freaks!), easy GUI creation, and so many other things that we haven't even gotten into.
I'll be posting examples based upon things in my lab and lecture, including full programs, certain syntax, and other cool things. My teacher is very good and explains many things, so you have him at your disposal (meaning, ask me a question I don't know and I'll ask him, learn it, then explain it back to you!).
Lets get started with basic syntax then get into all the fun stuff.
Lets go over variables really quick. First of all, variables are declared or initialized with the "$" character. In C++ or Java we say "int variable = 0" or the such, but in Perl it's unique.
In Perl, we initialize numeric variables with the command:
my $variable = 0;
which would mean we create the variable "variable" and set it equal to zero. To just declare it it's as simple as just saying "my $variable"
Now you might be confused with the "my" command. This deals with the SCOPE of the variable. Many of you probably know what "scope" means, but if you don't, here's a quick definition.
The "scope" of a variable can be thought of as the lifetime of that variable, or where it can be referenced in your code. If you declare a variable in one block of code (say, a for loop), but try to change it outside of it, Perl won't allow it since it can't "see" the variable because it's "dead" or out of our scope!
I'm sure you'll all understand the "my" command soon enough, it's pretty simple and doesn't require much thought; just make sure you use it when declaring and initializing variables for the first time.
Now, remember how I said we initialize "numeric variables" with the above command? Well, you might be surprised to hear that numeric variables and strings are created the same way!
Here's how we create a simple string:
my $string = "this is some text to equal string";
and it's as simple as that.
Perl looks at the value of the variable rather than the type, so you don't have to say "double" or "int" or "string"!
Lets talk a but more about variables in Perl. Every PERL variable has three components: The name, address, and value.
Take this line of code for instance:
my $pet = "Noah";
The name is "pet", the address in memory is hidden right now, and the value is "Noah".
The address (called a reference as well) can be shown by a "scalar" and placed into another variable:
my $pet_ref = \$pet;
Note the \$...
Like in C++, this is the REFERENCE (shown in C++ by the asterisk *); it references the address in memory.
The following line of code prints the variable that we placed the reference of $pet into:
print $pet_ref;
...which would be the memory location!
I'll be posting examples based upon things in my lab and lecture, including full programs, certain syntax, and other cool things. My teacher is very good and explains many things, so you have him at your disposal (meaning, ask me a question I don't know and I'll ask him, learn it, then explain it back to you!).
Lets get started with basic syntax then get into all the fun stuff.
Lets go over variables really quick. First of all, variables are declared or initialized with the "$" character. In C++ or Java we say "int variable = 0" or the such, but in Perl it's unique.
In Perl, we initialize numeric variables with the command:
my $variable = 0;
which would mean we create the variable "variable" and set it equal to zero. To just declare it it's as simple as just saying "my $variable"
Now you might be confused with the "my" command. This deals with the SCOPE of the variable. Many of you probably know what "scope" means, but if you don't, here's a quick definition.
The "scope" of a variable can be thought of as the lifetime of that variable, or where it can be referenced in your code. If you declare a variable in one block of code (say, a for loop), but try to change it outside of it, Perl won't allow it since it can't "see" the variable because it's "dead" or out of our scope!
I'm sure you'll all understand the "my" command soon enough, it's pretty simple and doesn't require much thought; just make sure you use it when declaring and initializing variables for the first time.
Now, remember how I said we initialize "numeric variables" with the above command? Well, you might be surprised to hear that numeric variables and strings are created the same way!
Here's how we create a simple string:
my $string = "this is some text to equal string";
and it's as simple as that.
Perl looks at the value of the variable rather than the type, so you don't have to say "double" or "int" or "string"!
Lets talk a but more about variables in Perl. Every PERL variable has three components: The name, address, and value.
Take this line of code for instance:
my $pet = "Noah";
The name is "pet", the address in memory is hidden right now, and the value is "Noah".
The address (called a reference as well) can be shown by a "scalar" and placed into another variable:
my $pet_ref = \$pet;
Note the \$...
Like in C++, this is the REFERENCE (shown in C++ by the asterisk *); it references the address in memory.
The following line of code prints the variable that we placed the reference of $pet into:
print $pet_ref;
...which would be the memory location!
Open for answer!:
it's about time someone posted a easy to understand pearl tutorial
ReplyDeleteDude you are awesome, good luck in your studies and learn all you can kind sir.
ReplyDeleteI've been wanting to learn perl.
ReplyDelete2016-3-23 leilei
ReplyDeletemichael kors handbags
converse shoes
jimmy choo shoes
cheap oakley sunglasses
rolex replica watches
michael kors outlet
valentino store
fitflops clearance
ralph lauren outlet
longchamp
polo ralph lauren
christian louboutin shoes
ray ban sunglasses
coach outlet store online
armani jeans
stephen curry shoes
prada uk
ralph lauren outlet
christian louboutin uk
coach factory outlet
michael kors outlet
coach factory outlet
coach outlet online
gucci borse
cheap jordans
canada goose sale
louboutin
coach outlet online
ecco shoes
marc jacobs handbags
coach factory outlet
ralph lauren
ray ban sunglasses
coach outlet online
abercrombie & fitch
nike running shoes
michael kors outlet
hollister uk
babyliss flat iron
cheap jordan shoes
soccer jerseys
ReplyDeletetoms outlet
lululemon outlet
michael kors handbags clearance
ray ban sunglasses
air max 90
cartier outlet store
swarovski outlet
louis vuitton outlet store
oakley sunglasses
rolex watches
lebron shoes
michael kors factory outlet
oakley sunglasses
oakley sunglasses
michael kors outlet
hollister clothing store
mulberry outlet
cartier watches for sale
adidas outlet store
ralph lauren polo
rolex watches
true religion outlet
rolex watches for sale
longchamp handbags
mulberry handbags sale
timberland shoes
cazal outlet
omega watches
louis vuitton outlet
longchamp pas cher
cheap oakley sunglasses
michael kors outlet online
michael kors handbags
mulberry sale
chanyuan0523
chenlina20160625
ReplyDeletehollister clothing
polo outlet
kate spade handbags
michael kors purses
michael kors handbags
louis vuitton
ralph lauren outlet
nike huarache
michael kors outlet
cheap oakley sunglasses
fitflop sandals
jordan 8
nike free run
insanity workout
replica watches
oakley sunglasses
polo ralph lauren
cheap ray ban sunglasses
air max 90
ralph lauren polo
designer handbags
kobe 11
kate spade outlet
fitflops sale clearance
kobe bryant shoes
louis vuitton outlet stores
rolex submariner
oakley outlet
louis vuitton outlet stores
louis vuitton handbags
adidas superstars
rolex watches
louis vuitton outlet
coach factory outlet
michael kors handbags
longchamp bags
michael kors outlet
running shoes
coach factory outlet
ghd hair straighteners
as
ferragamo shoes
ReplyDeletenike air huarache
longchamp pliage
burberry outlet
omega watches
true religion jeans sale
soccer jerseys
true religion canada
adidas wings
toms shoes
michael kors outlet
hermes outlet store
lebron shoes
michael kors outlet
coach outlet online
ralph lauren outlet
coach outlet online
celine outlet online
soccer jerseys
true religion uk
louis vuitton neverfull
michael kors clearance
hollister clothing
burberry sunglasses on sale
michael kors handbags
michael kors uk
nike soccer shoes
uggs outlet
gucci outlet online
ugg boots
ugg boots
versace sunglasses
uggs outlet
louis vuitton pas cher
ralph lauren polo
20160729caihuali
rolex watches
ReplyDeletecheap ray ban sunglasses
canada goose outlet
coach factory outlet
washington wizards jerseys
ugg boots
ugg uk
tiffany and co
christian louboutin outlet
fitflop shoes
2016.11.17chenlixiang
coach outlet store online
ReplyDeletereebok sneakers
ralph lauren polo outlet
fitflop uk
coach outlet
chanel outlet
nike air max
louis vuitton sac
levi's jeans outlet store
louis vuitton bags
2017.2.20chenlixiang
christian louboutin outlet
ReplyDeletecoach outlet online
pandora jewelry
nike shoes outlet
san francisco giants jerseys
cheap jordans
polo ralph lauren outlet
adidas shoes
louboutin shoes
fred perry
20170313caiyan
christian louboutin shoes
ReplyDeletemont blanc pen
ralph lauren sale
cheap nike sneakers
cubs jerseys
pandora outlet
ralph lauren uk
fit flops
red bottom heels
coach outlet online
170522yueqin
coach bags
ReplyDeletekate spade
asics
oakley sunglasses
uggs outlet
jordans
longchamp outlet
nike blazer shoes
air max
louboutin
20183.7wengdongdong
ppsspp gold apk games download for games Apk download from here
ReplyDeleteI had been involved in c++ programming classes many years ago, and I learned well then, but now how many years have I forgotten how much time does it take to train again?
ReplyDeleteتابلو چلنيوم
تابلو مغازه
adidas yeezy boost
ReplyDeleteadidas gazelle sale
air max 2018
goyard handbags
chrome hearts outlet
goyard bag sale
adidas shoes online
ferragamo sale
lebron 14
jordans
ReplyDeleteشركة تنظيف بيوت بالدمام
ارخص شركة نقل عفش بالاحساء
افضل شركة كشف تسربات المياه بالاحساء
ارخص شركة نقل عفش بمكة
ReplyDeleteشركة نقل اثاث من الرياض الى الامارات
لاننا افضل شركات شحن الاثاث فدائما خدماتنا هى الافضل
شركة شحن عفش من الرياض الى الاردن
اتصل بنا الان للحصول على افضل الخدمات لاننا الافضل دائما ونعمل على الاستعانة بافضل العمالة المدربة على نقل العفش و فك وتغليف الاثاث لاننا افضل و
ارخص شركة نقل عفش بجدة