Beginner Perl Help

Soldato
Joined
27 Aug 2004
Posts
2,955
Location
Singapore ExPat
Hi Guys,

Have just started learning perl this week and it seems to be going well but I have hit a brick wall. I'm trying to do something I think should be relatively simple, just read lets say the output of the free command on linux. All I want to do is read each line into an array so I can play with the values a little.

Is an array the most sensible approach for this? Or should I use a hash? It seems that when I do this the whole lines get put into the first part of the array, lets say $array[0] whereas I want each word to do into each part of the array. I tried using split but can't seem to find the appropriate regex to split on the values.

Can anyone help?

Cheers!
 
Thank you for that, it is beyond helpful, I am going to try this out tomorrow at work and see if I can't get this to behave as I want. Obviously this is my first week so need to get my head around the hash syntax. Hope you don't mind if I ask a couple more questions tmrw! Thanks again.

Mike
 
Back
Top Bottom