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对每 ...
随机推荐
- 一个简单的php函数调用实例
需求分析: funcs.php (这个文件,我们定义了一个函数) <?php //我们一个计算,+ - * / 的代码集合->函数 //1. function 是一个关键字 //2. ji ...
- s3c6410学习笔记-将内核zImage、文件系统写到nandflash、屏幕校准
1.之前已经将uboot写到nandflash里面了,接下来将内核zImage.文件系统写到nandflash. 2.编译内核 cd linux-2.6.28_smdk6410 make clean ...
- java 一致性哈希类实例 算法
package com.hash; import java.util.Collection; import java.util.SortedMap; import java.util.TreeMap; ...
- mysql binlog 混合模式 出现的基于sql的数据不一致,主要是now()这类函数导致
- ldap理论属于概念缩略词
Standalone LDAP Daemon, slapd(standalone lightweight access protocol) ldap 389 default listener port ...
- 截取字符串一之substring
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- S3C6410嵌入式应用平台构建(六)——linux-3.14.4移植到OK6410-(Yaffs2文件制作)
本文主要讲怎用利用yaffs2工具和busybox制作yaffs2文件系统镜像.大多数都是参照网上的,目的在于记录学习,不做任何用途. 一.制作mkyaffs2image工具 进入yaffs2源码目录 ...
- Problem 2128 最长子串(kmp+strstr好题经典)
Problem 2128 最长子串 Accept: 134 Submit: 523Time Limit: 3000 mSec Memory Limit : 65536 KB Probl ...
- C++ 清空消息队列
在button等被禁用后,可能须要它在禁用期间不去响应不论什么消息. 能够使用以下的语句片段: MSG msg; //消耗掉消息队列中的全部消息 while(::PeekMessage(&ms ...
- CSS蒙版
蒙版:就是在图片上添加一个图层,用于美化页面,增加页面的可读性 <!DOCTYPE html><html><head lang="en"> &l ...