in reply to Parsing a string for sorting

How about this one liner.
my $string="001003051"; &verify($_) for(split /(\d{3})/, $string);
If you are worried about non-numbers creeping into your string, you would have to add a 'tr'. --eric

Replies are listed 'Best First'.
RE: Re: Parsing a string for sorting
by merlyn (Sage) on Aug 08, 2000 at 04:19 UTC
    I've really fallen in disfavor with using the "delimiter capturing" mechanism of split, when the list-context m//g is so much more direct and controllable:
    verify($_) for $string =~ /\G(\d{3})/g;
    There. Now there's no chance that "012xxx345xxx678" will try to verify the 345 and 678, as it would for the split example (not to mention passing the xxx parts to verify.

    -- Randal L. Schwartz, Perl hacker