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对每 ...
随机推荐
- node 的 异步 数据库 调用 处理
相信很多人在使用node 的时候, 一方面会觉得他强大的异步性感到很方便. 但是有时候我们却非要程序能按我们自己的想法 去串行的执行我们的思路. 同样我在编写的过程中也遇到类似的问题,比如for 和 ...
- IE 第三方设置cookie失效
公司的产品,采用多服务分摊压力,中间必须涉及的当然是单点登陆.一般的单点登陆都是通过去用户中心登陆,302或页面回调的方式,返回到登陆前的页面. 公司项目,想用户体验更好些,采用弹框登陆,可以考虑if ...
- 项目从Codeigniter 2.2升级至 Codeigniter 3.0的一些注意事项
1. 替换掉system目录下所有的文件和文件夹,以及替换掉index.php 2. controllers和models中的文件首字母都需要改成大写:application.php -> Ap ...
- CPU核心数
Process.ProcessorAffinity 属性: public IntPtr ProcessorAffinity { get; set; }属性值:位掩码,表示关联进程内的线程可以在其上运行 ...
- 【Howie玩docker】-使用mono编译c#程序
根据前面的方法,在windows和Linux共享文件夹,然后就可以开发了! Start up an Ubuntu container $ docker run -it ubuntu bash Upda ...
- Java判断字符串是否为空的三种方法
方法一: 最多人使用的一个方法, 直观, 方便, 但效率很低.1: if(s == null || s.equals("")); 方法二: 比较字符串长度, 效率高, 是我知道的最 ...
- 16.java.lang.InterruptedException
java.lang.InterruptedException 被中止异常 当某个线程处于长时间的等待.休眠或其他暂停状态,而此时其他的线程通过Thread的interrupt方法终止该线程时抛出该异常 ...
- Case when 的用法,简单Case函数
Case when 的用法,简单Case函数 简单CASE表达式,使用表达式确定返回值. 语法: CASE search_expression WHEN expression1 THEN result ...
- php正则表达式图谱
php 正则表达式分类图:
- Qt Windows下链接子系统与入口函数(终结版)(可同时存在main和WinMain函数)
Qt Windows下链接子系统与入口函数(终结版) 转载自:http://blog.csdn.net/dbzhang800/article/details/6358996 能力所限,本讨论仅局限于M ...