Perl `split` does not `split` to default array

Viewed 570

I have this strange problem with split in that it does not by default split into the default array.

Below is some toy code.

#!/usr/bin/perl

$A="A:B:C:D";
split (":",$A);
print $_[0];

This does not print anything. However if I explicitly split into the default array like

#!/usr/bin/perl

$A="A:B:C:D";
@_=split (":",$A);
print $_[0];

It's correctly prints A. My perl version is v5.22.1.

2 Answers
Related