<2>集腋成裘
标量项: [root@wx03 2]# cat a1.pl
unshift(@INC,"/root/big/2");
use Horse;;
print $Horse::days;
print "\n";
[root@wx03 2]# cat Horse.pm
package Horse;
our $days="test111";
1; $Horse::days; 访问Horse 包中的变量$days 有时候你想为"所有名叫foo的东西"(无论他的印记是什么)起一个名字 。为此, 符号团记录可以有一个*作为前缀,这里的星号(*)表示所有其 他的印记。 这些称为类型团(typeglobs) perl main包: [root@wx03 2]# cat a2.pl
$bert="aa";
print "\$bert is $bert\n";
print "\$::bert is $::bert\n";
print $main::bert;
print "\n";
[root@wx03 2]# perl a2.pl
$bert is aa
$::bert is aa
aa 2.6.3 选择自己的引号: ` ` qx// 执行命令 是 [root@wx03 2]# cat a4.pl
@arr=`ls -ltr`;
print @arr;
print "\n"; @arr=qx/ls -ltr/;
print @arr;
print "\n"; [root@wx03 2]# cat a5.pl
print __LINE__;
print "\n";
print __FILE__;
print "\n";
print __LINE__;
print "\n";
[root@wx03 2]# perl a5.pl
1
a5.pl
5 __LINE__ 当前行号 __FILE__ 当前文件 [root@wx03 2]# cat a6.pl
print __PACKAGE__;
print "\n";
[root@wx03 2]# perl a6.pl
main 当前包为main包 [root@wx03 2]# cat a7.pl
print "111111111\n";
print "222222222\n";
print __END__;
print "333333333\n";
[root@wx03 2]# perl a7.pl
111111111
222222222
[root@wx03 2]# END 可以用于真正的文件结束符之前表示搅拌的逻辑结束, 任何后面的文本都被忽略 [root@wx03 2]# cat a8.pl
sub funkshun{
return(a1,a2,a3)}; $x=funkshun(); print "\$x is $x\n"; @x=funkshun();
print "\@x is @x\n"; [root@wx03 2]# perl a8.pl
$x is a3
@x is a1 a2 a3 2.7.3 空(void )环境: [root@wx03 2]# cat a9.pl
$stuff = ( "one", "two", "three");
print "\$stuff is $stuff\n";
[root@wx03 2]# perl a9.pl
$stuff is three 只是把值"three" 赋予了变量$stuff [root@wx03 2]# cat a10.pl
@stuff = ("one", "two", "three");
print "\@stuff is @stuff\n"; $stuff = @stuff;
print "\$stuff is $stuff\n";
[root@wx03 2]# perl a10.pl
@stuff is one two three
$stuff is 3 [root@wx03 2]# cat a11.pl
@stuff=(1,2,3);
@nonsense=(4,5,6);
sub funkshun{
return 100; }; @arr=(@stuff,@nonsense,funkshun());
print @arr;
print "\n";
print $arr[6];
print "\n";
[root@wx03 2]# perl a11.pl
123456100
100 [root@wx03 2]# cat a12.pl
%map = (
red => 0xff0000,
green => 0x00ff00,
blue => 0x0000ff,
); print $map{red};
print "\n";
[root@wx03 2]# perl a12.pl
16711680 初始化任何当作记录使用的匿名散列引用: [root@wx03 2]# cat t1.pl
$rec = {
NAME => 'John Simth',
RANK => 'Captain',
SERNO => '951413',
}; print $rec->{NAME};
print "\n";
[root@wx03 2]# perl t1.pl
John Simth 或者用命名的参数激活复杂的函数: 2.10 型团(typeglob) Perl 里面有种特殊的类型叫类型团(typeglob)用以保留整个符号表 记录。(符号表记录
*foo 包括 $foo, @foo, %foo,&foo 和其他几个 foo 的简单解释 值。)类型团
(typeglob)的类型前缀上一个 *,因为它代表所有类型。 [root@wx03 2]# cat t3.pl
$fh=*var;
$var=aa;
print "\$fh is $fh\n"; print "\$fh is $$fh\n"; [root@wx03 2]# perl t3.pl
$fh is *main::var
$fh is aa [root@wx03 2]# cat t3.pl
$fh=*var;
$var=aa;
print "\$fh is $fh\n"; print "\$fh is $$fh\n"; $bar="bbb";
*foo = \$bar;
print "\$foo is $foo\n"; $a1="aaaa111";
*foo=\$a1;
print $foo;
print "\n";
[root@wx03 2]# perl t3.pl
$fh is *main::var
$fh is aa
$foo is bbb
aaaa111 符号表就是引用: [root@wx03 2]# cat t4.pl
$bar="abc123";
*foo=\$bar;
print *foo;
print "\n"; print $foo;
print "\n";
[root@wx03 2]# perl t4.pl
*main::foo
abc123 2.11.2 行输入(尖角)操作符
[root@wx03 2]# cat t5.pl
while ($_ = <STDIN>) { print $_; };
[root@wx03 2]# perl t5.pl
1
1
33
33
<2>集腋成裘的更多相关文章
- 集腋成裘-13-git使用-02进阶篇
上一篇我们简单介绍了如何安装和使用git,本次将简单介绍如何创建分支.处理冲突.提交与回滚 创建和合并分支是Git的一大特色. 使用场景:当有一个新功能要开发,但是又没有确定上线时间,不能合并到主干上 ...
- 集腋成裘-12-git使用-01创建库
一.git安装教程 git安装比较简单,选择好安装路径,直接默认下一步即可 1:检查git是否安装成功 二.SourceTree工具 1:下载&安装 安装过程中如何免注册? 在C:\Users ...
- 集腋成裘-11-sql性能优化
SQL Nexus是一个用于将SQL Trace数据.性能监视日志及T-SQL输出整合进一个单独的SQL Server数据库的工具. 先决条件 开始使用SQL Nexus之前,注意下面要做的事项: 安 ...
- 集腋成裘-09-ECharts -HelloECharts-02
上一篇我们讲了可视化数据分析的重要性以及ECharts的一些的特性,这一篇我们继续学习一下ECharts的简单Demo 一:5 分钟上手 ECharts <!DOCTYPE html> & ...
- 集腋成裘-08-ECharts -简介-01
目标:让数据说话. 大数据时代的到来以及有效应用,大幅度提升了企业的管理能力.决策科学化与可执行性水平,推动传统决策方式朝着数据驱动转型.可视化数据分析对决策者产生的意义将在事前预测.事中感知以及事后 ...
- 集腋成裘-06-angularJS -angular_02
1.0 选项卡 其中涉及到了三目运算符号; <!DOCTYPE html> <html ng-app="test"> <head> <me ...
- 集腋成裘-05-angularJS -初识angular
私以为angular的最大特点是:只关注数据 1.1 angular之:双向绑定 <!DOCTYPE html> <html ng-app=""> < ...
- 集腋成裘-03-css基础-02
1.1 三种写法 内嵌式:样式只作用于当前文件,没有真正实现结构表现分离 外链式:作用范围是当前站点,真正实现了内容与表现分离 行内样式:仅限于当前标签,结构混在一起 1.2 标签分类 1.2.1 块 ...
- 集腋成裘-02-css基础-01
CSS 层叠样式表(Cascading Style Sheets)(级联样式表) 1 选择器 1.1 写法 选择器是一个选择标签的过程. 选择器{属性:值;...} 1.2 基础选择器 标签选择器 类 ...
随机推荐
- [转]Centos6.5安装配置keepalived
参考博文: Centos6.5安装配置keepalived CentOS6.5 keepalived详解及实现Nginx服务的高可用性 CentOS6.5 LVS + KeepAlived搭建步骤 我 ...
- windows和centos用cutycapt截网页的图
centos下:(主要参考http://loosky.net/2816.html) (1)安装qt47 增加qt47的源 vim /etc/yum.repos.d/atrpms.repo //加入如下 ...
- vim 小技巧总结
1.v+移动光标可以选中文本. 2.y可以复制已经选中的文本 3.p可以粘贴 复制一行则:yy 复制当前光标所在的位置到行尾:y$ 复制当前光标所在的位置到行首:y^ 复制三行则:3yy,即从当前光标 ...
- JavaScript 的数组操作--删除元素
在JavaScript中,可以很方便的删除指定位置的元素,这个是用到 splice方法, 该方法用于删除或替换数组中的部分数据. 其语法定义是 : splice(start , count [,new ...
- 给centOs添加epel源
epel简介: https://fedoraproject.org/wiki/EPEL/zh-cn 1. rpm -Uvh http://dl.fedoraproject.org/pub/epel/5 ...
- [Android] FileInputStream跟踪
1. 源起 需要跟踪FileInputStream的Read的Nativie实现,开始走了弯路,Java工程下的FileInputStream实现与Android工程的实现不同.另外,http://b ...
- NYOJ-开灯问题
开灯问题 时间限制:3000 ms | 内存限制:65535 KB 难度: 描写叙述 有n盏灯,编号为1~n.第1个人把全部灯打开,第2个人按下全部编号为2 的倍数的开关(这些灯将被关掉),第3 ...
- UVa 725暴力求解
A - Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Su Description Writ ...
- CentOS6.5 服务器+apache5.3绑定多个域名+SELinux设置
下面简单的介绍了如何通过设置Apache的http.conf文件,进行多个域名以及其相关的二级域名的绑定(假设我们要绑定的域名是minidx.com和ntt.cc,二级域名是blog.minidx.c ...
- 64位CentOS6.2安装erlang及rabbitmqServer
CentOS 6.2 64bit 安装erlang及RabbitMQ Server 1.操作系统环境(CentOS 6.2 64bit) [root@HAproxy ~]# cat /etc/issu ...