当前位置: 首页 > news >正文

daily notes[7]

文章目录

  • perl note
  • references

perl note

  1. A hash in perl can be initialized with array,for example:
my %numbers = ("one", 1, "two", 2);
print $fruit_color{"one"};  
  1. it is wonderful that the hash can be sliced to result in an array as similar as array.for example:
my %numbers = ("one", 1, "two", 2,"three",3);
my @nums= @numbers{"one","three"};
print @nums;
13
  1. keys and values get all keys and all values of a hash .by the way,the slicing in hash also is a hash.for example:
my %numbers = ("one", 1, "two", 2,"three",3,"uno",1);
my %nums= %numbers{"one","three","uno"};
print keys %nums;
print values %nums;
unoonethree113
  1. the value in hash of perl can belong to a hash even any other Perl data type.
my $numbers = {"two"=> {"due"=>2,"二"=>2},"three"=>3};
print $numbers->{"two"}->{"二"};
print $numbers->{"three"};
23
  1. unless you want to create a global variable ,you ought to use my to identify the variable scoping.
  2. the loop structure of perl is similar as most programming language.
while ( condition ) {...
}
until ( condition ) {...
}
for ($k = 0; $k <= $max; $k++) {...
}
foreach my $key (keys %hash) {print "the $key corresponding to  $hash{$key}\n";
}
  1. regular expression
.                   a single character
\s                  a whitespace character (space, tab, newline, ...)
\S                  non-whitespace character
\d                  a digit (0-9)
\D                  a non-digit
\w                  a word character (a-z, A-Z, 0-9, _)
\W                  a non-word character
[aeiou]             matches a single character in the given set
[^aeiou]            matches a single character outside the givenset
(foo|bar|baz)       matches any of the alternatives specified^                   start of string
$                   end of string
*                   zero or more of the previous thing
+                   one or more of the previous thing
?                   zero or one of the previous thing
{k}                 matches exactly k of the previous thing
{k1,k2}               matches between k1 and k2 of the previous thing
{k1,}                matches k1 or more of the previous thing

references

  1. https://learn.perl.org/
http://www.dtcms.com/a/361631.html

相关文章:

  • Windows系统下如何配置和使用jfrog.exe
  • Ansible变量的定义与使用
  • docker 网络配置
  • MJ Prompt Tool-好用的Midjourney提示词工具
  • uniApp 混合开发全指南:原生与跨端的协同方案
  • 机器学习通关秘籍|Day 05:过拟合和欠拟合、正则化、岭回归、拉索回归、逻辑回归、Kmeans聚类
  • ChatGLM-6B全流程部署:环境搭建→模型加载→API调用(附避坑指南)
  • 【项目思维】这是一份嵌入式软件开发的大纲(简化版)
  • Go 面试题: new 和 make 是什么,差异在哪?
  • window显示驱动开发—监视筛选器驱动程序
  • 如何安装CUDA????
  • 在 Qt 中加载 .qm 翻译文件
  • 基本问题解决--舵机
  • 选择图片转base64格式组件简单封装-Base64ImageInpu
  • nestjs 发起请求 axios
  • Onion-LO(已开源)——LIDAR里程计的统一框架
  • IO进程线程;标准io;文件IO;0901
  • PyTorch 实战(3)—— PyTorch vs. TensorFlow:深度学习框架的王者之争
  • 「日拱一码」075 机器学习——密度泛函理论DFT
  • 在 Unity 中调用腾讯云机器翻译
  • 命名空间级别应用 Pod 安全标准
  • 在 Ubuntu 24.04 LTS 上安装 SSH 并启用服务端实现远程连接
  • 别再刷屏console.log!JavaScript高级调试方法全攻略
  • Product Hunt 每日热榜 | 2025-08-30
  • C++“类吸血鬼幸存者”游戏制作的要点学习
  • IO_HW_9_1
  • 【零碎小知识点 】(二)Java基础与常用API编码实践
  • day2
  • 【STM32】中断软件分支处理( NVIC 和 GIC)
  • curl 介绍及使用教程