给变量赋值是什么意思? [英] What does assigning 'shift' to a variable mean?

查看:58
本文介绍了给变量赋值是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例:

use strict;
my $file = shift;

open(IN, $file) || die "Unable to open $file\n";
open(OUT, ">$file.$$") or die $!;

my $file = shift 是怎么回事?

推荐答案

如果在主程序中使用,它将shift(移除并返回)来自@ARGV的第一个值code>,程序的参数列表.如果在子程序中使用,它将从子程序的参数列表 @_ 中移动第一个值.有关详细信息,请参阅文档.

If used in the main program, it will shift (remove and return) the first value from @ARGV, the argument list of your program. If used inside a subroutine, it will shift the first value from @_, the argument list of the sub. See the documentation for more info.

这篇关于给变量赋值是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆