Perl概述
@home = ("couch", "chair", "table", "stove"); 数组
数组.一个数组是多个标量的有序列表
因为数组是有序的,所以你可以在它上面做很多很有用操作.例如堆栈操作 push 和 pop
散列,散列是一组无序标量
%longday = (
"Sun" => "Sunday",
"Mon" => "Monday",
"Tue" => "Tuesday",
"Wed" => "Wednesday",
"Thu" => "Thursday",
"Fri" => "Friday",
"Sat" => "Saturday",
);
$longday{"Wed"}
$wife{"Jacob"} = ["Leah", "Rachel", "Bilhah", "Zilpah"]; # 正确
这个语句创建了一个未命名的数组,并将这个数组的引用放入散列的元素 $wife{“Jacob”} 中
1.2.4 复杂数据结构
[root@wx03 1]# cat a2.pl
$wife{"Jacob"} = ["Leah", "Rachel", "Bilhah", "Zilpah"];
print $wife{"Jacob"}->[1];
print $wife{"Jacob"}[1];
print "\n";
use Data::Dumper;
$str=Dumper($wife{"Jacob"});
print "\$str is $str\n";
[root@wx03 1]# perl a2.pl
RachelRachel
$str is $VAR1 = [
'Leah',
'Rachel',
'Bilhah',
'Zilpah'
];
[root@wx03 1]# cat a4.pl
[root@wx03 1]# cat t2.pl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
$ua->timeout(99);
$ua->env_proxy;
$ua->agent("Mozilla/147258369.0");
my $response = $ua->get('http://120.55.118.6:3000/api/auto_publish/publish?env=uat&app=zjzc-hy-core-02&ip=121.40.x91.x1');
use Data::Dumper;
$str=Dumper($response);
print $str;
print "\n";
[root@wx03 1]# perl t2.pl
$VAR1 = bless( {
'_request' => bless( {
'_headers' => bless( {
'user-agent' => 'Mozilla/147258369.0'
}, 'HTTP::Headers' ),
'_method' => 'GET',
'_content' => '',
'_uri' => bless( do{\(my $o = 'http://120.55.118.6:3000/api/auto_publish/publish?env=uat&app=zjzc-hy-core-02&ip=121.40.1x1.xx')}, 'URI::http' )
}, 'HTTP::Request' ),
'_content' => 'Can\'t connect to 120.55.1x8.x:3000
Connection refused at /usr/local/perl/lib/site_perl/5.22.1/LWP/Protocol/http.pm line 47.
',
'_headers' => bless( {
'::std_case' => {
'client-warning' => 'Client-Warning',
'client-date' => 'Client-Date'
},
'client-warning' => 'Internal response',
'client-date' => 'Sun, 15 May 2016 14:15:42 GMT',
'content-type' => 'text/plain'
}, 'HTTP::Headers' ),
'_rc' => 500,
'_msg' => 'Can\'t connect to 120.55.118.6:3000'
}, 'HTTP::Response' );
$kids_of_wife{"Jacob"} = {
"Leah" => ["Reuben", "Simeon", "Levi", "Judah", "Issachar", "Zebulun"],
"Rachel" => ["Joseph", "Benjamin"],
"Bilhah" => ["Dan", "Naphtali"],
"Zilpah" => ["Gad", "Asher"],};
print $kids_of_wife{"Jacob"}->{Rachel}->[1];
[root@wx03 1]# perl a4.pl
Benjamin[root@wx03 1]#
1.6.3.4 跳出控制结构: next 和 last
[root@wx03 1]# cat t3.pl
@users=qw/a b c d e f g/;
foreach $user (@users){
if ($user eq c) {next;}
else {print "\$user is $user\n";};
if ($user eq d){last;};
};
[root@wx03 1]# perl t3.pl
$user is a
$user is b
$user is d
next 操作符运行你跳至本地循环的结束,开始下一个循环
last 操作符允许你跳至整个循环的结束
1.2.5 简单数据结构
$wife{"Jacob"} Jacob键对应的值是一个数组引用
[root@wx03 1]# cat a3.pl
$ua=["Leah", "Rachel", "Bilhah", "Zilpah"];
print $ua->[0];
print "\n";
[root@wx03 1]# perl a3.pl
Leah
Perl概述的更多相关文章
- <1> perl概述
[root@wx03 1]# cat a1.pl $arr=[1,2,3,4,5,6]; print $arr->[4]."\n"; $hash={a=>1,b=> ...
- Perl语言编程(大骆驼)
啰嗦几句 Perl的时代已经过去,现在年轻的同事们基本上都在用Python了.但个人认为单就生物信息文本处理而言,Perl语言是绝对够用的.最主要的是,前辈们搭建的流程大多数是Perl写的,因此,如果 ...
- perl 继承概述
<pre name="code" class="html">[root@wx03 test]# cat Horse.pm package Horse ...
- 【原创】Aspose.Words组件介绍及使用—基本介绍与DOM概述
本博客所有文章分类的总目录:http://www.cnblogs.com/asxinyu/p/4288836.html 本博客其他.NET开源项目文章目录:http://www.cnbl ...
- 【多端应用开发系列1.1.1 —— Android:使用新浪API V2】服务器Json数据处理——Json数据概述
[前白] 一些基础的东西本系列中就不再详述了,争取尽量写些必不可少的技术要点. 由于本系列把Web Service 构建放到了第二部分,Android项目就采用新浪微博API v2作为服务器端. [原 ...
- Aspose.Words组件介绍及使用—基本介绍与DOM概述
1.基本介绍 Aspose.Words是一个商业.NET类库,可以使得应用程序处理大量的文件任务.Aspose.Words支持Doc,Docx,RTF,HTML,OpenDocument,PDF,XP ...
- [HeadFirst-JSPServlet学习笔记][第一章:前言与概述]
第一章 前言与概述 web服务器做什么? 答:接收客户请求,然后向客户返回结果 web客户做什么? 答:此处客户指浏览器,web客户允许用户请求服务器上的某个资源,并向用户展现请求的结果. html ...
- 2.Perl基础系列之入门
官网提供的入门链接:http://perldoc.perl.org/perlintro.html 语法概述 Perl的安装步骤省略,直接去官网下载并按照提示安装即可. 如果Perl安装没问题,那么运行 ...
- perl5 第一章 概述
第一章 概述 by flamephoenix 一.Perl是什么?二.Perl在哪里?三.运行四.注释 一.Perl是什么? Perl是Practical Extraction and Re ...
随机推荐
- javascript 横向下拉菜单演示
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN"><head><me ...
- ppt类似工具AxeFile使用心得
一个所谓的傻瓜式过渡效果自动生成工具.定义好展示窗口大小,加入时序.所谓的闪烁效果,也是相当的滑稽. 是一个非专业的简单的快速PPT工具. 但是体现的确是扁平化的设计思路,很值得深思. ------ ...
- System.Web.Security 在winform中是什么命名空间呢
des.Key = ASCIIEncoding.ASCII.GetBytes(System.Web.Security.FormsAuthentication.HashPasswordForStorin ...
- PHP学习笔记14-操作session
PHP会话管理图: 创建index: <?php /** * Created by PhpStorm. * User: Administrator * Date: 2015/7/2 * Time ...
- codeforces 464C. Substitutes in Number
题目链接 C. Substitutes in Number time limit per test 1 second memory limit per test 256 megabytes input ...
- Flask中全局变量的实现
我们都知道在Flask中g,request,session和request是作为全局对象来提供信息的,既然是全局的又如何保持线程安全呢,接下来我们就看看flask是如何做到这点的.在源码中的ctx.p ...
- hdu 4790 Just Random 神奇的容斥原理
/** 大意: 给定[a,b],[c,d] 在这两个区间内分别取一个x,y 使得 (x+y)%p = m 思路:res = f(b,d) -f(b,c-1)-f(a-1,d)+f(a-1,c-1); ...
- 解决gerber-Failed to Match All Shapes for PCB问题
有效解决在Protel 99se导gerber时提示gerber-Failed to Match All Shapes for PCB出错问题如图 这种问题很好解决,打开这个窗口 操作方法如下图Emb ...
- hibernate的配置 1
hibernate 是一种ORM框架,是ORM框架中一个典范 ORM叫做对象关系映射 是面向对象语言和关系型数据库之间的映射关系 所以只有在面向对象语言或者关系型数据库没用的时候ORM才会消失 ORM ...
- 大数据计算:如何仅用1.5KB内存为十亿对象计数
大数据计算:如何仅用1.5KB内存为十亿对象计数 Big Data Counting: How To Count A Billion Distinct Objects Using Only 1.5K ...