Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: indefinite number of columns

by zork42 (Monk)
on Jul 15, 2013 at 14:05 UTC ( #1044383=note: print w/ replies, xml ) Need Help??


in reply to indefinite number of columns

if I want column 1 entries to go in one array , second column entry to another and so on . How can i define my array
The easiest solution is to have an array or arrays, AoA for short. These are 2D arrays. See:
To understand AoA's you'll need to learn about references:
You can then store each field in $AoA[row number][column number]
It's unlikely you'll need to ask the user how many columns there are.

Update: doh! Cross posted with marto and hippo, though luckily I think together our posts explain different levels and aspects of the solution.

Text::CSV is definitely the way to go!


Comment on Re: indefinite number of columns
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2015-07-30 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls