Perl split string based on forward slash

Viewed 7866

I am new to Perl, so this is basic question. I have a string as shown below. I am interested in taking date out of it, so thinking of splitting it using slash

my $path = "/bla/bla/bla/20160306";
my $date = (split(/\//,$path))[3];#ideally 3 is date position in array after split
print $date;

However, I don't see the expected output, but instead I see 5 getting printed.

3 Answers
Related