Sleep 是一种基于 java 开发的脚本语言

http://sleep.dashnine.org/manual/index.html

基础语法

# create Arrays
@foo = @('two',3.0,'four');  # This is Arrays
$foo = @(1, 2, 3, "four");  

# println();
println($foo + @foo);
# Hashes 类似 Python 的字典 key value

%dic = %(a => "one", b => "two", c => "three", d => 4);
$dic = %(a => "one", b => "two", c => "three", d => 4);

$a = "5";
$b = "f";
%dic["e"] = "$a";
%dic[$b]     = "6";

println("%dic is: " . %dic);

# 输出
%dic is: %(a => 'one', b => 'two', c => 'three', d => 4, e => '5', f => '6')
# write file
$file = openf(">demo.txt");
$data = "test file text";
writeb($file, $data);
closef($file);

# read file
$file = openf("demo.txt");
$data = readb($file, -1);
println($data);
closef($file);
# split 字符串分割成数组

> x split(" ", "Hello World")
@('Hello', 'World')

> x split(",", "baidu.com,qq.com,secbook.info")
@('baidu.com', 'qq.com', 'secbook.info')
# foreach 循环遍历字典

%data = %(a => "hello", b => "world", c => "fuck", d => "sleep");
foreach $var (keys(%data)) # foreach keys
{
   println($var);
}

foreach $var (values(%data)) # foreach values
{
   println($var);
}

@array = @("one",2,3,4.0,5);
foreach $var (@array) # foreach array
{
   println($var);
}

warn 函数输出的内容中包含了当前代码的文件名和行数,可用来 debug

参考:http://sleep.dashnine.org/manual/index.html

待定

标签: 安全工具

添加新评论

marisa.png