in reply to How can I split a string into fixed-length parts, rather than on delimiters?

Yet another way, using the fact that if you put parens around the split() argument, it's kept in the output instead of discarded:
@parts = split /(.{4})/, '41084109.udp';
After this runs, print "@parts" will give you
4108 4109 .udp
Obviously, if the filename isn't exactly 8.4, you'll get the wrong answer, but it's an interesting use of split().

Replies are listed 'Best First'.
Re: Answer: How can I SPLIT a file name w/out delimiters ie: 41084109
by ikegami (Patriarch) on Nov 08, 2006 at 03:08 UTC
    Sounds like an overly complicated way of doing
    @parts = '41084109.udp' =~ /(.{4})/g;