差异点:
变量类型 |
数组 列表 哈希 指针/引用 |
变量使用 |
赋值 引用 set = $ |
结构分句 |
{} () ; |
结构控制 |
if else case switch for while |
文件 |
open close seek printf scanf read write |
子程序 |
sub/proc |
1)Csh Makefile
|
Csh |
Makefile |
|
变量 |
参数 |
$argv[1] $argv[2] $argv[*] |
-e case=100 |
列表 |
$array[0] |
obj = obj1 obj2 obj3 |
|
数组 |
|||
哈希/关联数组 |
|
|
|
指针/引用 |
|
|
|
赋值 |
|
set xxx = xxx setenv xxx xxx set names = ( Tom Dick Fred ) @ n=5+5 |
xxx = xxx |
引用 |
|
数组引用:$argv[n] 标准输入:$< 变量存在:$?name 成员个数:$#name 进程号: $$ |
$(variable) |
逻辑判断 |
|
&& || ! |
|
位运算 |
|
|
|
条件 |
if else |
if ( expression ) then ... else if ( expression ) then ... else ... endif |
ifeq ifneq ifdef ifndef
ifeq (...) ... else ... endif
|
case |
switch ( "$xxx" ) case xxx: ... breaksw case xxx: ... breaksw default: ... endsw |
|
|
? |
|
|
|
循环 |
for |
|
for number in 1 2 3 4 ; do \ |
foreach |
foreach variable ( word list ) ... end |
$(foreach VAR,LIST,CMD 1;CMD 2;)
|
|
repeat |
repeat 3 "echo helloworld" |
|
|
while |
while ( expression ) ... continue ... break ... end |
number=1 ; while [[ $$number -le 10 ]] ; do \ |
|
自动标号 |
|
objects = file1.o file2.o file3.o all: $(objects) $(objects): %.o: %.cpp |
|
跳转 |
goto |
goto ... |
|
文件 |
fopen |
输出重定向到文件为: > -e 文件存在返回1(.true.) :t (tail)只保留路径名最右边的部分, 而将前面的全部去掉. (相当于basename) |
|
fclose |
|
|
|
子程序 |
|
|
|
|
|
|
2)Perl Tcl
|
Perl https://www.runoob.com/perl/perl-tutorial.html |
Tcl https://www.yiibai.com/tcl |
|
变量 |
参数 |
$ARGV[0] $ARGV[1] |
|
列表 |
@a = qw(abc def ghi) @a = (1..10) |
set listName {item1 item2 .. itemN }
set var {orange blue red green} |
|
数组 |
set arrName(index) value |
||
哈希/关联数组 |
哈希: %hash
$hash{$key} = $value; my %fruit=(apple=>"fruit",banana=>'fruit');
二维哈希: $hash{$key1}{$key2} = $value;
foreach my $key1 (keys %hash) { foreach my $key2 (keys %$hash2 ) } |
dict set colours colour1 red
set colours [dict create colour1 "black" colour2 "white"] |
|
指针/引用 |
$scalarref = \$foo; # 标量变量引用
ref($ref_var) # 返回引用类型 |
|
|
赋值 |
|
$xxx = xxx; $xxx = "xxx" |
set a 100 |
引用 |
|
$xxx $xxx[0] $hash{$key} $hash-> {$key} |
$a |
逻辑判断 |
|
>= lt gt eq |
|
位运算 |
|
& | ! ^ |
|
条件 |
if else |
if (xxx) {
unless(boolean_expression){ |
if {...} { ... } else { ...
|
case |
use Switch;
|
switch switchingString { matchString1 { body1 matchString2 { body2 bodyn } |
|
? |
Exp1 ? Exp2 : Exp3; |
|
|
循环 |
for |
for( $a = 0; $a < 10; $a = $a + 1 ) { |
for { set a 10} {$a < 20} {incr a} { puts "value of a: $a" } |
foreach |
foreach $a (@list) { |
foreach var {a b c d e f} {
foreach var1 {a b c} var2 {d e} { |
|
repeat |
|
|
|
while |
while(...) { ... }
do
until(...) { ... } |
whiel {...} {
break continue |
|
自动标号 |
|
|
|
跳转 |
goto |
goto continue next last redo |
break continue |
文件 |
fopen |
open(fin, " while( print fout $xxx; |
set fid [open "xxx.txt" r] set fid [open "xxx.txt" w]
puts $fid $xxx |
fclose |
close fin; close fout; |
close fid |
|
子程序 |
define |
sub sub_routine{ my @list = @_; ... return xxx; ... }
|
proc sum {arg1 arg2} { |
call |
&sub_routine($a, @b); |
sum 1 2 |
3)Matlab C SV
|
Matlab https://www.yiibai.com/matlab |
C https://www.yiibai.com/cprogramming/ |
SV http://testbench.in/ |
|
变量 |
参数 |
|
int main(int argc, char* argv[]); argc // 参数个数 argv[1] // 参数1 |
|
列表 |
|
|
|
|
数组 |
a = [1,2;3,4]; |
a[0] = 100; |
a[0] = 100; |
|
哈希/关联数组 |
|
|
data_type array_id [ index_type ];
bit [20:0] array_b[string]; |
|
指针/引用 |
|
int *ptr; *ptr = xxx; |
|
|
赋值 |
|
a = 3; |
a[0] = 100; |
a[0] = 100; |
引用 |
|
a = b; |
a = b; |
a = b; |
逻辑判断 |
|
|
|
|
位运算 |
|
|
|
|
条件 |
if else |
if a>0 ... elseif ... else ... end
|
if (...) { ... } else if() { ... } else { ... } |
if (...) begin ... end else if() begin ... end else begin ... end |
case |
switch n |
switch(...) { case xxx: default: |
case(...) xxx: xxx: default: endcase |
|
? |
|
|
c = sel ? a : b; |
|
循环 |
for |
for i=0:8 for i=0:2:8 for i=[1,2,3] |
for (int i = 1; i< 10; i++) { |
for (i = 1; i< 10; i++) begin |
foreach |
|
|
int array1[0:7][0:3];
foreach(array1[i][j])begin ... end |
|
repeat |
|
|
repeat 5 begin ... end |
|
while |
while (xxx) ... end
break continue |
while () {
do {
break |
while () begin .. end
|
|
自动标号 |
|
|
|
|
跳转 |
goto |
|
goto xxx |
disable xxx; |
文件 |
fopen |
fseek
data = fscanf(fid,format,size);
fread |
FILE *fp; fseek
fscanf fprintf
fread |
integer fp; fseek
fscanf fprintf
fread |
fclose |
||||
子程序 |
define |
function [output] = f(input) |
sub_routine (int a, int b) { ... } |
function sub(reg a, reg b); ... sub = xxx; ... endfunction |
call |
[output] = f(input) |
sub_routine (a,b); |
a = sub(a,b); |