in reply to discussion: What should split( /PATTERN/, EXPR, 0 ) return better?

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1201251 use strict; use warnings; print "K sum"; for my $K ( 0..5 ) { my $sum = 0; $sum += ($_ // 0) for (split ' ', "5 6 7 8\n")[0 .. $K-1]; print "$K $sum"; }

Try yours with strict and warnings and see what you get

  • Comment on Re: discussion: What should split( /PATTERN/, EXPR, 0 ) return better?
  • Download Code