Installing perl and writing your first perl program in Ubuntu
Installing perl and writing your first perl program in Ubuntu
Installing perl and writing your first perl program in Ubuntu
Filed under Perl
12
What Is Perl?Perl is an acronym, short for Practical Extraction and Report Language. It was designed by Larry Wall as a tool for writing programs in the UNIX environment and is continually being updated and maintained by him. For its many fans,
Perl provides the best of several worlds. For instance: Perl has the power and flexibility of a high-level programming language such as C. In fact, as you will see, many of the features of the language are borrowed from C.
Like shell script languages, Perl does not require a special compiler and linker to turn the programs you write into working code. Instead, all you have to do is write the program and tell Perl to run it. This means that Perl is ideal for producing quick solutions to small programming problems, or for creating prototypes to test potential solutions to larger problems.
Perl provides all the features of the script languages sed and awk, plus features not found in either of these two languages. Perl also supports a sed-to-Perl translator and an awk-to-Perl translator.In short, Perl is as powerful as C but as convenient as awk, sed, and shell scripts.
How to install Perl on UbuntuPerl is located in the ubuntu repositories, you can install it by the following command.
sudo apt-get install perl
perl is installed in usr/bin/
Writing your first perl program
1
2
3
4
5
#!/usr/bin/perl
# A simple perl program to print the user input
print ("Hello, type in something\n");
$inputline=;
print ($inputline);Lets split up the code and see what each line does..
#!/usr/bin/perl
# Says this line is a comment and there are no executable instructions on this line
! Says this is a perl script
/usr/bin/perl give the location of the perl interpreter, many programing books mention the location as usr/local/bin/perl, but this is not correct in ubuntu. In ubuntu Perl interpreter is located at usr/bin/perl.
print “Hello, type in something\n”;
This line just prompts to user to type something, similar to printf statement in C.
$inputline=<stdin>
Here we are setting a variable named inputline, and storing the input from the keyboard into that variable. <stdin> takes the input from the keyboard.
print ($inputline);
This line echoes the typed in message.
Running your first Perl programCopy the above above program in to your favorite text editor and save it as myFirstPerlProgram.pl and then change it to a executable, you can do that by typing the following in the terminal
chmod +x myFirstPerlProgram.pl
now you can run this code by typing myFirstPerlProgram.pl in the terminal
Output of the above perl programOutput of the above perl program
Installing perl and writing your first perl program in Ubuntu的更多相关文章
- Writing an Hadoop MapReduce Program in Python
In this tutorial I will describe how to write a simpleMapReduce program for Hadoop in thePython prog ...
- 用Python语言写Hadoop MapReduce程序Writing an Hadoop MapReduce Program in Python
In this tutorial I will describe how to write a simple MapReduce program for Hadoop in the Python pr ...
- ZooKeeper - Perl bindings for Apache ZooKeeper Perl绑定用于 Apache ZooKeeper
ZooKeeper - Perl bindings for Apache ZooKeeper Perl绑定用于 Apache ZooKeeper 监控 master/slave 需要使用zk的临时节点 ...
- Perl入门(七) Perl脚本的调试
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/sunshoupo211/article/details/32711165 编程中错误不可避免.调试可 ...
- Linux perl: warning: Setting locale failed.perl: warning: Please check that your locale settings:
使用 apt-get 安装软件时,总是出现下面的错误. perl: warning: Setting locale failed. perl: warning: Please check that y ...
- Perl入门(三)Perl的数组
Perl数组的声明方式 Perl使用"@"符号声明一个数组:@array: 使用"()"或"qw()"声明数组中元素: 一个完整的声明方式为 ...
- perl 简单学习,安装perl模块
检查是否安装了某个perl模块 有多种方式 0.perldoc perlinstall 列出所有的模块及版本号 1. perl -M模块名 -e 1(模块名不加空格) 没有返回值则说明有此模块 2.p ...
- 【Perl学习笔记】2. perl中的bless理解
bless有两个参数:对象的引用.类的名称. 类的名称是一个字符串,代表了类的类型信息,这是理解bless的关键. 所谓bless就是把 类型信息 赋予 实例变量. 程序包括5个文件:person.p ...
- 【Perl学习笔记】1.perl的ref 函数
perl有引用的概念:一组数据实际上是另一组数据的引用.这些引用称为指针,第一组数据中存放的是第二组数据的头地址.引用的方式被用得相当普遍,特别是在面向对象的模块.函数的参数传递等常见.但perl对每 ...
随机推荐
- 使用fastcgi_cache加速网站
为了提高网站的性能缓存是一把利器,nginx中可以配置fastcig_cache来缓存不需要实时获取的数据实现动静分离,nginx.conf配置如下: http { - fastcgi ...
- spring 源码之IOC 类图
Spring IoC容器是spring框架的核心和基础,IoC容器负责spring Bean的生命周期,是spring框架实现其他扩展功能的基础.容器的继承结构比较复杂,这里画出了spring IoC ...
- 简单的表单验证(js、jquery)
//javascript代码 function valForm(){ var username=document.getElementById("username"); var p ...
- pickle模块
在编程中,如果存在大的列表或者字典,可以在python中引入pickle 模块: 例如:将下边这组列表保存到文件当中:[1, 2, 'xiaomao', '小狗'] 程序: import pickle ...
- [原创]C语言里为何会有“2+2=5”的结果
原文链接:C语言里为何会有“2+2=5”的结果 写这篇原创文章是因为看到了极客中的一篇文章<有趣各种编程语言实现2+2=5>,其中C语言是这样实现的: int main() { ″; // ...
- #include <memory>
1 auto_ptr 2 unique_ptr 1 auto_ptr C++的auto_ptr所做的事情,就是动态分配对象以及当对象不再需要时自动执行清理. 使用std::auto_ptr,要#inc ...
- 自定义标签体、MVC
自定义标签 文件以tld结尾,放在webinfo中 标签名 引用类 标签体 继承SimpleTagSupport,复写doTag() getContext(); getjspBody() invo ...
- Delphi XE7中新并行库
Delphi XE7中添加了新的并行库,和.NET的Task和Parellel相似度99%. 详细内容能够看以下的文章: http://www.delphifeeds.com/go/s/119574 ...
- JavaScript之面向对象学习八(继承)
简介:继承是OO语言中的一个最为人津津乐道的概念.许多OO语言都支持两种继承方式:接口继承和实现继承.接口继承只继承方法签名,而实现继承则继承实际的方法. 但是JS的函数并没有签名,所以在ECMASc ...
- IIS7.5(IIS7)配置伪静态urlrewrite
找了好久,终于找到了.已经测试通过,收藏. 转载自:http://jingyan.baidu.com/article/67508eb4ff92c69cca1ce49a.html 首先新建一个应用程序池 ...