in reply to What is the most efficient way to split a long string (see body for details/constraints)?

Hi mikegold10

Maybe you can still achieve what you want with very minor changes to your existing code

But, using split, although easy, leads to extra parsing (beyond the last field I need) and produces a complete array of fields which I also don't need.

Really? Try using this split in this form:

split /PATTERN/,EXPR,LIMIT

If LIMIT is specified and positive, it represents the maximum number of fields into which the EXPR may be split; in other words, LIMIT is one greater than the maximum number of times EXPR may be split. Thus, the LIMIT value 1 means that EXPR may be split a maximum of zero times, producing a maximum of one field (namely, the entire value of EXPR).

See split - perldoc.perl.org

Cheers,
Shadowsong

  • Comment on Re: What is the most efficient way to split a long string (see body for details/constraints)?
  • Select or Download Code