Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by shadowsong (Pilgrim)
on Jun 19, 2019 at 15:35 UTC ( [id://11101580]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11101580]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found