Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Perl (http://www.go4expert.com/forums/perl/)
-   -   Creating a 2D perl array to store data (http://www.go4expert.com/forums/creating-2d-perl-array-store-data-t27171/)

teknokid1 17Nov2011 20:51

Creating a 2D perl array to store data
 
Respected All,

Kindly help me out.

I have got file listings in a directory like this:

-rw-r--r-- 1 root root 115149 2011-11-17 07:15 file1.stat.log
-rw-r--r-- 1 root root 115149 2011-11-18 08:15 file2.stat.log
-rw-r--r-- 1 root root 115149 2011-11-19 09:15 file3.stat.log
-rw-r--r-- 1 root root 115149 2011-11-20 10:15 file4.stat.log
-rw-r--r-- 1 root root 115149 2011-11-21 11:15 file5.stat.log


I am storing this output in the @data array as mentioned below:

foreach $_(`ls -lrt *stat*`)
{
@data = split " ", $_;
}


Now, I want to create a 2D array of 5x3 dimensions, Let's say output[][] in perl, to store the
desired information.This column of 2D array's output[][] will be filled by @data array's 6th,7th and 8th columns.
I want to use referances.

#
like

output[][] =
data[6] data[7] data[8]
data[6] data[7] data[8]
data[6] data[7] data[8]
data[6] data[7] data[8]
data[6] data[7] data[8]


The desired info will be

output[][] =

2011-11-17 07:15 file1.stat.log
2011-11-18 08:15 file2.stat.log
2011-11-19 09:15 file3.stat.log
2011-11-20 10:15 file4.stat.log
2011-11-21 11:15 file5.stat.log

I want to create a function for this and want to return this 2D array output[][] as the result.

Please help me out.
I shall be very thankful to you.

Warm Regards,
Teknokid1


All times are GMT +5.5. The time now is 10:08.