in reply to Convert an array of numbers into a range

#!/usr/bin/perl -l # http://perlmonks.org/?node_id=1168288 use strict; use warnings; my $list = '0001,0002,0003,011,012,013,015'; print $list =~ s/\b(\d+)(?{$1})\K(?:,(\d+)\b(??{++$^R!=$2}))+/-$2/gr;

Replies are listed 'Best First'.
Re^2: Convert an array of numbers into a range
by rmocster (Novice) on Jul 22, 2016 at 00:38 UTC
    I get this error: Bareword found where operator expected on the print line. Execution aborted due to compilation errors.

      Too old a perl ?

        Error on my Linux system running Perl v5.10.1 Will try it on my OSX.