Perl shift operator simple question

后端 未结 5 1957
离开以前
离开以前 2021-01-19 03:33

What\'s the purpose of the following two lines of perl??

my $host = shift || \'localhost\';
my $port = shift || 200;

That should return loc

5条回答
  •  旧时难觅i
    2021-01-19 04:01

    If you use shift, always put the array on it. I've seen experience Perl programmers forget that outside a subroutine, shift works on @ARGV. The more things a programmer has to remember at the same time, the more likely he is to make an error.

提交回复
热议问题