I am currently learning perl and when I encountered a piece of code explainng how to traverse a directory tree using recursive subroutines. This is the code in question
use strict;
use warnings;
use 5.010;
my $path = shift || '.';
traverse($path);
sub traverse {
my ($thing) = @_;
return if not -d $thing;
opendir my $dh, $thing or die;
while (my $sub = readdir $dh) {
next if $sub eq '.' or $sub eq '..';
say "$thing/$sub";
traverse("$thing/$sub");
}
close $dh;
return;
}
I understood the subroutine and how it works, however I did not understand this statement: (my $path = shift || '.';) I know that it is the variable that is passed to the subroutine, but I do not know what value it takes. Thanks in advance.