子例程 subroutine
#! /usr/bin/perl
use strict;
use warnings;
print "\n---------summation_STDIN_parameter----------\n";
sub total{
my $array_len = @_;
my $sum = 0;
foreach(0..$array_len){
$sum += $_[$_];
#sum += 1;
}
return $sum;
}
my @comma = qw{ 3 5 1 7 9};
my $dash = &total(@comma);
print "Sum is: $dash.\n";
print "Enter some numbers on seperate lines:";
my $dollar_sign = &total(<STDIN>);
print "Sum of those numbers is: $dollar_sign.";
print "\n---------summation_STDIN_parameter----------\n";
print "\n---------_sum_1..1000----------\n";
#my $dot_operator;
my $dot_operator = &total(1..1000);
print "Sum of 1..1000 is: $dot_operator.";
print "\n---------_sum_1..1000----------\n";
子例程 subroutine的更多相关文章
- 分析Tornado的协程实现
转自:http://www.binss.me/blog/analyse-the-implement-of-coroutine-in-tornado/ 什么是协程 以下是Wiki的定义: Corouti ...
- gcc g++ 参数介绍
C和C++ 编译器是集成的.他们都要用四个步骤中的一个或多个处理输入文件: 预处理 (preprocessing),编译(compilation),汇编(assembly)和连接(linking).源 ...
- 维多利亚的秘密 golang入坑系统
原文在gitbook,字字原创,版权没有,转载随意. 在写本文的前一天,2017维密在上海开始了. 为了纪念屌丝界的盛世,特为本节起名维多利亚的秘密.现在的社会,要想出名只有抓眼球.所以写份技术文章, ...
- Haskell语言学习笔记(72)Free Monad
安装 free 包 $ cabal install free Installed free-5.0.2 Free Monad data Free f a = Pure a | Free (f (Fre ...
- 维多利亚的秘密 golang入坑系列
原文在gitbook,字字原创,版权没有,转载随意. 在写本文的前一天,2017维密在上海开始了. 为了纪念屌丝界的盛世,特为本节起名维多利亚的秘密.现在的社会,要想出名只有抓眼球.所以写份技术文章, ...
- 【转载】 GNU GCC 选项说明
GCC 1 Section: GNU Tools (1) Updated: 2003/12/05 Sponsor: GCC Casino Winning Content NAME gcc,g++-GN ...
- gcc, g++ - GNU 工程的 C 和 C++ 编译器 (egcs-1.1.2)
总览 (SYNOPSIS) gcc [ option | filename ]... g++ [ option | filename ]... 警告 (WARNING) 本手册页 内容 摘自 GNU ...
- Routine Subroutine Coroutine 子程序 协程 子例程
https://en.wikipedia.org/wiki/Subroutine In computer programming, a subroutine is a sequence of prog ...
- perl学习之子例程
1.system function && user function system fucntion:chomp reverse print... user function: & ...
随机推荐
- 访问linux的mysql-没有iptables文件的情况,防火墙开启3306端口
转自:https://blog.csdn.net/wangt_1224/article/details/45824095
- (转)Repeater中增加序号自增列
<%# Convert.ToString(Container.ItemIndex+)%> 当Repeater空为时,提示没有数据... <FooterTemplate> < ...
- HDU 5916 Harmonic Value Description (构造)
题意:给你 n 和 m,求一个1-n的排列,使得∑gcd(Ai,Ai+1) 恰为第 m 小. 析:可以想到最小的就是相邻都互质,然后依次,第 m 小就可以有一个是gcd为 k,然后其他的为1喽. 那 ...
- E20180205-hm
insensitive adj. 不敏感的; 感觉迟钝的; (对某事物) 无感觉的; (对变化) 懵然不知的; occurence 出现,发生; capital n. 资本; 首都; 资源; 大写字 ...
- phpStudy安装配置小记
一.phpStudy简介 该程序包集成最新的Apache+PHP+MySQL+phpMyAdmin+ZendOptimizer,一次性安装,无须配置即可使用,是非常方便.好用的PHP调试环境·该程序不 ...
- css覆盖select样式并添加小箭头
.select { border-radius: 5px; border: 1px #F4A627 solid; -webkit-appearance: none;//清除默认样式 backgroun ...
- 使用了eclipse10年之后,我终于投向了IDEA
使用了eclipse10年之后,我终于投向了IDEA 最近,改用了idea,同事都说我投敌了.当然,这些同事都是和我一样的"老"程序员.不说毕业生,公司里的90后基本电脑都不会安装 ...
- python中字典的陷阱
把字典与列表组合,如 i=20 s=[]#定义一个空列表 b={'d':i}#定义一个字典 while i>0: i=i-1 b['d']=i#更新字典的值 s.append(b) print( ...
- [POJ2750]Potted Flower
Description The little cat takes over the management of a new park. There is a large circular statue ...
- poj 3164 Command Network (朱刘算法)
题目链接: http://poj.org/problem?id=3164 题目大意: 有n个点(用坐标表示)各点编号分别为1—>n,m条单向路,问能否存在一个花费价值最小的网络,能使从1点到达任 ...