Multiple choice technology programming languages

: What will be the size of the @fields array? my $record = ':a:b:c:'; my @fields = split(':', $record, -1);

  1. 0

  2. 1

  3. 3

  4. 5

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In Perl, split with a negative limit parameter preserves all trailing empty fields. The string has a colon at the beginning and the end, creating empty fields at both boundaries. Splitting ':a:b:c:' yields five elements: empty, 'a', 'b', 'c', and empty.