Learn-Perl

所属分类:collect
开发工具:Perl
文件大小:0KB
下载次数:0
上传日期:2022-04-13 01:42:44
上 传 者sh-1993
说明:  一个存储库,用于展示我对Perl编程语言的知识,并继续学习该语言。,
(A repository for showcasing my knowledge of the Perl programming language, and continuing to learn the language.,)

文件列表:
.editorconfig (1327, 2022-04-12)
... ...

*** ![/Programming-republic-of-perl.png](https://github.com/Programming-republic-of-perl.png) ### Learning Perl I am not too experienced with the Perl programming language at the moment. This document will go over my knowledge of the Perl language so far. This document uses version 5.36 of the Perl programming language. ( [Main repository (GitHub:///seanpm2001/Learn/)](https://github.comhttps://github.com/seanpm2001/Learn/) | [Perl 5 development repository (GitHub)](https://github.comhttps://github.com/Perl/perl5/) | [Browse source code](https://github.com/Learn-Perl/Samples/) ) #### [Comments in Perl](https://github.com/Learn-Perl/Samples/Comments/) Comments in Perl are the same as comments in languages like Shell, Python, Ruby, etc. ```perl # This is a single line comment """ This is a multi- line comment """ ''' This is also a multi-line comment """ ``` #### [Break keyword in Perl](https://github.com/Learn-Perl/Samples/Break-Keyword/) ```perl break ``` To this day, I am still not entirely sure what the `break` keyword does, but most languages support it. _/!\ This example has not been tested yet, and may not work_ #### [Hello World in Perl](https://github.com/Learn-Perl/Samples/Hello-World/) A hello world program in Perl is pretty simple. It is similar to Python, except it requires a newline character and a semicolon, but doesn't require parentheses. ```perl # Hello World in Perl print "Hello World\n"; ``` _/!\ This example has not been tested yet, and may not work_ #### [Shebangs in Perl](https://github.com/Learn-Perl/Samples/Shebang/) Shebangs/hashplings in Perl are similar in style to other shebangs in languages like Shell, Python, D, etc. They go on the very first line of the program, and define what implementation the program is using, and the language. ```perl #!/usr/bin/env perl """ My Perl program """ print "This Perl program uses a shebang.\n"; ``` _/!\ This example has not been tested yet, and may not work_ #### [Wait keyword in Perl](https://github.com/Learn-Perl/Samples/Wait-Keyword/) Similar to Python's `sleep` Perl has a `wait` keyword that delays further commands for a given amount of time. The syntax works like this: ```perl #!/usr/bin/env perl print("I will speak again in 10 seconds\n"); wait 10; print("I have spoken\n"); break; ``` _/!\ This example has not been tested yet, and may not work_ #### [Functions in Perl](https://github.com/Learn-Perl/Samples/Functions/) The process of making functions in Perl is easy, but it was a bit difficult to find for some reason: ```perl #!/usr/bin/env perl $func1 = "Function 1 is defined"; ``` _/!\ This example has not been tested yet, and may not work_ #### [Checking functions in Perl](https://github.com/Learn-Perl/Samples/Checking-Functions/) To check if a function works, one does the following: ```perl #!/usr/bin/env perl # Redefining functions $func1 = "Function 1 is defined"; # Chcking the existance of functions if(defined($func1)) { print($func1\n); } if(defined($func2)) { print($func2\n); } else { print "Function 2 is not definedn"; } ``` _/!\ This example has not been tested yet, and may not work_ This was inspired by [GeeksforGeeks](https://github.comhttps://www.geeksforgeeks.org/perl-defined-function/) the reference source code is: ```perl #!/usr/bin/perl # Defining a variable $X = "X is defined"; # Checking for existence of $X # with defined() function if(defined($X)) { print "$X\n"; } # Checking for existence of $Y # with defined() function if(defined($Y)) { print "Y is also defined\n"; } else { print "Y is not defined\n"; } ``` _/!\ This example has not been tested yet, and may not work_ #### [Calling a function in Perl](https://github.com/Learn-Perl/Samples/Calling_Functions/) Calling a function in Perl is very easy, and similar to many languages, such as PHP, etc. ```perl #!/usr/bin/env perl # Redefining functions $func1 = "Function 1 is defined"; print ($func1) ``` _/!\ This example has not been tested yet, and may not work_ #### [Use keyword in Perl](https://github.com/Learn-Perl/Samples/Use-Keyword/) Perl has a declarative keyword known as `use` it is used like this: ```perl #!/usr/bin/env perl use strict; # Uses strict mode use warnings; # Gives out warnings ``` _/!\ This example has not been tested yet, and may not work_ #### [Integers in Perl](https://github.com/Learn-Perl/Samples/Integers/) Integers are defined in Perl as so: ```perl #!/usr/bin/env perl $int1 = int(2); $int2 = int(64); ``` _/!\ This example has not been tested yet, and may not work_ #### [If/else keywords in Perl](https://github.com/Learn-Perl/Samples/If-Else/) If and else are common keywords in Perl, just like most other programming languages. They are used as so: ```perl #!/usr/bin/env perl $x = int(2) if ($x / 2 != int) # This is pseudocode for now. What I am trying to do is have numbers that are odd be decimals, and for them to be signaled out. I may need to change the integer to a double to achieve this { print("X is even\n"); break; } else { print("X is odd\n"); break; } ``` _/!\ This example has not been tested yet, and may not work_ #### Source The majority of my Perl knowledge comes from browsing Perl code, browsing [Wikipedia](https://github.comhttps://en.wikipedia.org/wiki/Perl/), and self-experimenting with the language. #### Other knowledge of Perl 1. Perl is a curly bracket language and semicolon language 2. Perl 6 became Raku after development issues. 3. Perl has existed since 1987 4. Perl uses the `.pl` file extension, which can be confused with other languages, like Prolog 5. Perl is an open source programming language 6. Perl is often criticized for line noise, but not all Perl programmers see it this way 7. No other knowledge of D at the moment. *** ##### File info **File type:** `Markdown Document (*.md *.mkd *.mdown *.markdown)` **File version:** `1 (2022, Tuesday, April 12th at 4:27 pm PST)` **Line count (including blank lines and compiler line):** `0,238` **File languages:** `Markdown (CommonMark)` + `HTML (HTML 5.3)` + `English (US)` **All times are UTC-7 (PDT/Pacific Time)** `(Please also account for DST (Daylight Savings Time) until it is abolished/no longer followed)` _Note that on 2022, Sunday, March 13th at 2:00 am PST, the time jumped ahead 1 hour to 3:00 am._ ***

近期下载者

相关文件


收藏者