Perl Scripting Question

I know shift takes the element out from an array and single pipe symbol (|) is a bitwise or operator, but what two pipe symbols (||) is doing in below piece of code?

 
 #!/usr/bin/perl -w
  
 use strict;
  
 my $self = shift || 7899;
print "self: $self\n";
 

Thanks!

|| is a shorthand for OR, this is common in many C-like languages (or even algol descendants), so if the shift returns false (no element in the default array) the value of $self is set to 7899

1 Like