Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Is there any way to make an array non-greedy?

by thor (Priest)
on Oct 14, 2005 at 18:25 UTC ( [id://500343]=note: print w/replies, xml ) Need Help??


in reply to Re: Is there any way to make an array non-greedy?
in thread Is there any way to make an array non-greedy?

If my real problem were as easy as my toy script, I'd certainly follow one of your above solutions. However, it's more like this:
my ( $field1, $field2, #... $field25, @field26[0..25], $field27, $field28, #... ) = split(/\|/);
This way, it makes it obvious that I'm grabbing a fixed number from the split return. I appreciate the terseness in your solutions, though. Now that I know that it was a problem with my test data and not my approach, I'll be using something like what I originally posted.

thor

Feel the white light, the light within
Be your own disciple, fan the sparks of will
For all of us waiting, your kingdom will come

Replies are listed 'Best First'.
Re^3: Is there any way to make an array non-greedy?
by duff (Parson) on Oct 15, 2005 at 03:56 UTC

    I think you're after something like this:

    @important_fields = (split /\|/, $string)[25..50];

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-23 22:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found