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 Ubuntu

    Perl 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 program

    Copy 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 program

    Output of the above perl program

Installing perl and writing your first perl program in Ubuntu的更多相关文章

  1. Writing an Hadoop MapReduce Program in Python

    In this tutorial I will describe how to write a simpleMapReduce program for Hadoop in thePython prog ...

  2. 用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 ...

  3. ZooKeeper - Perl bindings for Apache ZooKeeper Perl绑定用于 Apache ZooKeeper

    ZooKeeper - Perl bindings for Apache ZooKeeper Perl绑定用于 Apache ZooKeeper 监控 master/slave 需要使用zk的临时节点 ...

  4. Perl入门(七) Perl脚本的调试

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/sunshoupo211/article/details/32711165 编程中错误不可避免.调试可 ...

  5. 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 ...

  6. Perl入门(三)Perl的数组

    Perl数组的声明方式 Perl使用"@"符号声明一个数组:@array: 使用"()"或"qw()"声明数组中元素: 一个完整的声明方式为 ...

  7. perl 简单学习,安装perl模块

    检查是否安装了某个perl模块 有多种方式 0.perldoc perlinstall 列出所有的模块及版本号 1. perl -M模块名 -e 1(模块名不加空格) 没有返回值则说明有此模块 2.p ...

  8. 【Perl学习笔记】2. perl中的bless理解

    bless有两个参数:对象的引用.类的名称. 类的名称是一个字符串,代表了类的类型信息,这是理解bless的关键. 所谓bless就是把 类型信息 赋予 实例变量. 程序包括5个文件:person.p ...

  9. 【Perl学习笔记】1.perl的ref 函数

    perl有引用的概念:一组数据实际上是另一组数据的引用.这些引用称为指针,第一组数据中存放的是第二组数据的头地址.引用的方式被用得相当普遍,特别是在面向对象的模块.函数的参数传递等常见.但perl对每 ...

随机推荐

  1. iis7.0/8.0rewrite规则

    首先在网站 web.config 配置文件的 configuration 节点中加入如下代码: <system.webServer> <rewrite> <rules&g ...

  2. struts2中使用json插件实现ajax交互

    json插件可以简单的实现ajax交互,避免了使用struts2-dojo-plugin.jar包时带来的struts2.x版本冲突问题.并且减少了使用ajax标签时需要的繁琐的配置包括web.xml ...

  3. APサーバ

    GlassFish GlassFish 是一款强健的商业兼容应用服务器,达到产品级质量,可免费用于开发.部署和重新分发. 简介 GlassFish 是用于构建 Java EE 5应用服务器的开源开发项 ...

  4. python 日期、时间戳转换

    获取当前日期: from datetime import datetime IN:datetime.now() OUT:datetime(2016,10,19,6,51,21,72341) 转化为字符 ...

  5. Orchard 源码探索(Log)

    简单工厂模式.抽象工厂模式和适配器模式 依赖倒置原则也叫依赖倒转原则,Dependence Inversion Principle,对抽象进行编程,不要对实现进行编程. A.高层次的模块不应该依赖于低 ...

  6. 深入Android媒体存储服务(一):APP与媒体存储服务的交互

    简介: 本文介绍如何在 Android 中,开发者的 APP 如何使用媒体存储服务(包含MediaScanner.MediaProvider以及媒体信息解析等部分),包括如何把 APP 新增或修改的文 ...

  7. 深入解析SSD中MLC与SLC的性能差异

    固态硬盘(Solid State Disk或Solid State Drive),也称作电子硬盘或者固态电子盘,是由控制单元和固态存储单元(DRAM或FLASH芯片)组成的硬盘. 固态硬盘的接口规范和 ...

  8. 文件转换dll mingw

    MinGW:c -> o           gcc -c a.cc -> exe         gcc a.c libs.o -o a.exe (从主程序a.c,附加libs,生成a. ...

  9. 【菜鸟学习Linux】-第一章-Linux环境搭建-安装VMware虚拟机

    本人菜鸟一个,刚毕业才上班2个月,现在用到Linux部署项目,这才开始学习Linux,以下是我在安装Linxu系统是遇到的一些问题,希望能给广大菜鸟们在学习的道路上提供帮助和指导,废话不多说!开工! ...

  10. 链表的实现 -- 数据结构与算法的javascript描述 第六章

    链表 链表是由一组节点组成的集合.每个节点都使用一个对象的引用指向它的后继.指向另一个节点的引用叫做链 结构示意图 : 链表头需要我们标识 head { element:head,next:obj1 ...