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 ...
随机推荐
- 转换GridView的内容到Excel里面 ---带有格式
http://www.aspsnippets.com/Articles/Export-GridView-to-Excel-in-ASPNet-with-Formatting-using-C-and-V ...
- Android中的一些基础知识(二)
这几天在回顾Android的基础知识,就把一些常见的知识点整理一下,以后忘了也可以翻出来看一看. 简单介绍一下Activity的生命周期 在API文档中对生命周期回调的函数描述的很详细,这里我只是翻译 ...
- iOS 项目中的NSNotification简单使用
iOS中NSNotification的简单使用 好久没有写过博客了,总是遇到问题查一下,今天查的又是一个老问题,想了想,还是记录一下!今天在项目开发中遇到一个配置及时性处理的问题,想了想之后决定用通知 ...
- python2.7_1.3_获取远程设备的IP地址
代码如下: # -*- coding: utf-8 -*- import socket def get_remote_machine_info(): remote_host = 'www.python ...
- 配置分割Tomcat日志
安装cronolog 官网下载:http://cronolog.org/usage.html ./configuremake;make install 或者 yum install cronolog ...
- [LeetCode]题解(python):022-Generate Parentheses
题目来源: https://leetcode.com/problems/generate-parentheses/ 题意分析: 题目输入一个整型n,输出n对小括号配对的所有可能性.比如说,如果输入3, ...
- 深入浅出—JAVA(4)
4.方法操作实例变量
- Cygwin ssh
http://www.evalumation.com/blog/86-cygwin-windows7-sshd
- Windows Azure 社区新闻综述(#76 版)
欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure 的社区推动新闻.内容和对话.以下是本周的亮点. 文章.视频和博客文章 · 更新 Windows Azure 中的 SQ ...
- Zend Studio 10.6.0汉化教程(图文)
来源于:http://www.pw88.com/teach/bangong/32.html 此汉化方法适用于所有的zend studio版本.整个汉化思路是:在线或者离线官方下载汉化包,本地安装即 ...