What is the meaning of shift and @ARG. [code] Package Name; use English; sub new { my $name = { the_first_name = >undef, the_last_name = >undef }; bless($name); return $ name; } sub first_name { my $self = shift; $self->{ the_first_name } = shift if @ARG; #please help me here return $self->{ the_first_name }; } [/code]
by zhshqzyc - Perl - 2006-11-08 09:19:04 阅读(2387) 回复(9)
#!/perl -w $index=1; my $dir=shift || '/root/perl'; my $tmp="dirlist.txt"; open(W,"> $tmp") || die "$!\n"; find(\&doit,$dir); close(W); sub doit { print_process_status($index); print W "$File::Find::name\n"; $index++; } sub print_process_status { my $i=shift; #这里的shift传了什么值给$i, my $j = $i % 4; SWITCH : { $j == 0 && do ...
我有两个选项t和s, 如果是-t -s 则我每次都shift一下就ok了 但是如果是-ts 我shift两次就错了 请教我怎样shift呢? 需要是这样的,我一个脚本aaa.sh 实现这样的功能 ./aaa.sh -l filename -t -s name1 name2 name3. 我需取name1 name2 name3作处理,所以想将选项shift掉这样就取到name*了 [ 本帖最后由 chzht001 于 2008-3-17 14:00 编辑 ]
The Java programming language also provides operators that perform bitwise and bit shift operations on integral types. The operators discussed in this section are less commonly used. Therefore, their coverage is brief; the intent is to simply make you aware that these operators exist. The unary bitwise complement operator "~" inverts a bit pattern; it can be applied to any of the integral types, ...
在自定义包里面 ... sub new { my $type = shift; #理解:$type 获取了class 的‘name’ ... 而现在 #!/usr/bin/perl sub errorMsg { my $lvl = shift; ... 请问,这里的shift是什么意思?获取的是什么信息?
有的时候用shift,有的时候用@_,搞不明白??? 例如: sub ff { my ($reff1, $reff2)=@_; #the difference between @_ and shift for ($index=0;$index<=$#$reff1; $index++) { $result[$index]=$reff1->[$index]+$reff2->[$index]; } 为啥改为shift之后就不好用了呢,他俩的本质区别在哪呢??当然还有$_,差点忘了。 谢谢了 [ 本帖最后由 joson12345 于 2006-5-8 15:55 编辑 ]
my $num = 12; print &hex($num),"\n"; # 我們自己寫的hex副常式 sub hex { my $param = shift; $num*2; } 定义一个这样的sub, 我想知道my $param = shift; 中的shift表示什么?
for x in `cat file` do echo $x ***** ----此处是否要shift done for x in $* do echo $x ***** ---此处是否要shift done