Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: array question

by kennethk (Abbot)
on Feb 02, 2015 at 20:13 UTC ( [id://1115319]=note: print w/replies, xml ) Need Help??


in reply to array question

It may be helpful to review How do I post a question effectively?. There are a few issues that the monks here are having in understanding your question.
  1. The data you have posted does not clearly map to data in memory. I'm guessing that your array initialization code would actually look like:

    my @array = ( 'a[1:0]', 'a[3:2]', 'a[5:4]', );
    but I could be wrong. This is why Anonymous Monk asked you to post your array initialization statement. Because of how you've presented it, my first thought was you has some weird array slice question.
  2. How one maps your dataset to your output is unclear. Again, I could guess at an answer (biggest first number, smallest second number), but that's just a guess. Does every element necessarily look like a[*:*]? You said you "tried with the hash", but it is unclear to me how a hash would solve this issue. Can you post your preliminary code that shows some results?

If I implemented this (based on some wild guesses), I'd use a regular expression in a for loop and cache the max and min in script-level variables. Or possibly use max and min from List::Util in conjunction with maps (e.g. my ($max) = max map /(\d)/, @list;). But this is largely dictated by your spec, which is poorly defined.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 17:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found