Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Difference between revisions of "Coding with Funtoo Linux/Perl 5 Tutorial"

From Funtoo
Jump to navigation Jump to search
(Created page with "This Perl programming tutorial is a great scripting guide to help you get started with programming in Perl under Funtoo Linux. We will list more Perl tutorials and programming...")
 
 
(4 intermediate revisions by 2 users not shown)
Line 13: Line 13:
}}
}}


This will display which version of Perl you have installed on your computer, if you want to install a different version of Perl Funtoo Linux has them sorted in kits. Don't worry  if you don't understand kits and what kits are. Let me just tell you there are two versions of Perl available in Funtoo Linux now, those are 5.26 and 5.28.  
This will display which version of Perl you have installed on your computer, if you want to install a different version of Perl Funtoo Linux has them sorted in kits. Don't worry  if you don't understand kits and what kits are.


So let's switch from 5.26 default version to 5.28 latest stable version by adding following lines in your /etc/ego.conf:
== First script ==
 
{{file|name=/etc/ego.conf|body=
[kits]
perl-kit=5.28-prime
}}
 
Now run:
{{console|body=
###i## ego sync && emerge -avuDN @world
}}


To see where perl interpreter is installed you can run:
To see where perl interpreter is installed you can run:
Line 36: Line 26:
{{file|name=hello.pl|lang=perl|desc=Hello world Perl script|body=
{{file|name=hello.pl|lang=perl|desc=Hello world Perl script|body=
#!/usr/bin/perl
#!/usr/bin/perl
print "Hello Funtoo!\n";
print "Hello, Funtoo!\n";
}}
 
Now make the script executable and you can run it.
 
{{console|body=
###i## chmod +x hello.pl
###i## ./hello.pl
Hello, Funtoo!
###i##
}}
}}


[[Category:Coding with Funtoo Linux]]
[[Category:Coding with Funtoo Linux]]

Latest revision as of 07:55, October 23, 2018

This Perl programming tutorial is a great scripting guide to help you get started with programming in Perl under Funtoo Linux. We will list more Perl tutorials and programming examples to master your knowledge of Perl Scripting later in this tutorial.

Perl, a high-level, general-purpose, interpreted, dynamic programming language. Perl is noted for its idiomatically rich syntax, its extensive use of regular expressions and the large module archive CPAN.

Perl was created by Larry Wall in 1987. It was originally developed to process text and produce reports . As a result, a backronym has been formed from its name: Practical Extraction and Report Language.

Installing Perl

Funtoo Linux stages come with Perl included. So there is nothing to install to get you started per se. You can check which version of Perl is installed by running:

root # perl -v

This will display which version of Perl you have installed on your computer, if you want to install a different version of Perl Funtoo Linux has them sorted in kits. Don't worry if you don't understand kits and what kits are.

First script

To see where perl interpreter is installed you can run:

root # which perl
   Note

Every script starts with shebang:"#!" which is not read as a comment. The first line is aactually a place where you put your interpreter which in this case is going to be perl.

   hello.pl (perl source code) - Hello world Perl script
#!/usr/bin/perl
print "Hello, Funtoo!\n";

Now make the script executable and you can run it.

root # chmod +x hello.pl
root # ./hello.pl
Hello, Funtoo!
root #