sub _browseruk_recognize_limited_urls { my ($input, $max) = @_; my @captures = $input =~ m[(https?://.+?)(?:,(?=http)|$)]g; return [ @captures[ 0 .. $max-1 ] ]; } #### capture.t .. not ok 1 - 1 URL # Failed test '1 URL' # at capture.t line 18. not ok 2 - 2 URLs (one containing a comma) ok 3 - 3 URLs (one containing a comma) ok 4 - Still only 3 URLs (one containing a comma); reject those over max 1..4 # Structures begin differing at: # $got->[1] = undef # $expected->[1] = Does not exist # Failed test '2 URLs (one containing a comma)' # at capture.t line 23. # Structures begin differing at: # $got->[2] = undef # $expected->[2] = Does not exist # Looks like you failed 2 tests of 4. Dubious, test returned 2 (wstat 512, 0x200) Failed 2/4 subtests Test Summary Report ------------------- capture.t (Wstat: 512 Tests: 4 Failed: 2) Failed tests: 1-2 Non-zero exit status: 2 Files=1, Tests=4, 1 wallclock secs ( 0.13 usr 0.04 sys + 0.11 cusr 0.05 csys = 0.33 CPU) Result: FAIL shell returned 1 #### sub _browseruk_recognize_limited_urls { my ($input, $max) = @_; my @captures = $input =~ m[(https?://.+?)(?:,(?=http)|$)]g; return [ grep { defined($_) } @captures[ 0 .. $max-1 ] ]; }