What's the purpose of the following two lines of perl??
my $host = shift || 'localhost';
my $port = shift || 200;
That should return localhost and port 10. What is the shift keyword??
The first line shifts from either @_
or @ARGV
(depending on where you are in the code), or in the absence of any contents in @_
/@ARGV
, assigns localhost
to $host
.
The second one should be self-explanatory now.
Have a look at the shift documentation for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With