Sponsored Content
Top Forums Shell Programming and Scripting Reading data into muti-dimentional array - in perl Post 50817 by Optimus_P on Monday 3rd of May 2004 02:21:54 PM
Old 05-03-2004
what you might want to take a look at is:

Code:
Learning Perl Objects, References & Modules.
5.2. Viewing Complex Data with Data :: Dumper

I used data dumper on your script above and this is what i get.

$VAR1 = [
          '1',
          '2',
          '3',
          '4'
        ];
$VAR1 = [
          '5',
          '6',
          '7',
          '8'
        ];
$VAR1 = [
          '9',
          '1',
          '2',
          '3'
        ];
$VAR1 = [
          '4',
          '5',
          '6',
          '7'
        ];

i think i know what your asking and if that is the case this is what is happening.

Code:
LINE: 1 )while (<InFILE> ) {
LINE: 2 )
LINE: 3 )@ar = split ;
LINE: 4 )
LINE: 5 )$arref = \@ar;
LINE: 6 )
LINE: 7 )push(@multiarray,$arref);
.....
....

line 1 says read each line in the file.
line 3 says for each space add a new element to @ar for each items read in $_. (IE: for the first line read in @ar=qw(1 2 3 4)Smilie
line 7 says for each entry to @ar create an anonymous array inside @multiarray. (IE:
@mulriarray=(
[1,2,3,4];
);
)


if you are trying to do something else be as detailed in your question as possable and i am sure we can get you sorted out and pointing in the right direction.

Last edited by Optimus_P; 05-03-2004 at 03:42 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

PERL: reading 2 column data into Hash file

I am trying to read in a 2 column data file into Perl Hash array index. Here is my code. #!/usr/bin/perl -w use strict; use warnings; my $file = "file_a"; my @line = (); my $index = 0; my %ind_file = (); open(FILE, $file) or die($!); while(<FILE>) { chomp($_); if ($_ eq '') { ... (1 Reply)
Discussion started by: subhap
1 Replies

2. Shell Programming and Scripting

Perl: Reading data from other file

Hi, I am writting some perl scripts for daily backup process. In which I want to pass some data/referance from another txt file. Text file contains only one column and multiple rows. I want to pass this data to variables of another perl script. e.g. Refdoc.txt file contains data as: perl1... (3 Replies)
Discussion started by: n.dba
3 Replies

3. Shell Programming and Scripting

Storing data in perl 2D array

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... (2 Replies)
Discussion started by: teknokid1
2 Replies

4. Shell Programming and Scripting

Perl Script for reading table format data from file.

Hi, i need a perl script which reads the file, content is given below. and output in new file. TARGET DRIVE IO1 IO2 IO3 IO4 IO5 ------------ --------- --------- --------- --------- --------- 0a.1.8 266 236 ... (3 Replies)
Discussion started by: asak
3 Replies

5. Shell Programming and Scripting

Reading from a file and assigning to an array in perl

I wrote a simply perl that searched a file for a particualr value and if it found it, rite it and the next three lines to a file. Now I have been asked to check those next three lines for a different value and only write those lines if it finds the second value. I was thinking the best way to... (1 Reply)
Discussion started by: billprice13
1 Replies

6. Shell Programming and Scripting

reading data from a file to an array

I need some help with this code below, i doesnt know why it will run twice with my function, but my function only got if else, any other way that can read line and put into array? while read line; do read -A array <<<$line n=${#array} for ((i=1;i<$n;i++)); do print... (1 Reply)
Discussion started by: gavin_L
1 Replies

7. Shell Programming and Scripting

Perl : Large amount of data put into an array

This basic code works. I have a very long list, almost 10000 lines that I am building into the array. Each line has either 2 or 3 fields as shown in the code snippit. The array elements are static (for a few reasons that out of scope of this question) the list has to be "built in". It... (5 Replies)
Discussion started by: sumguy
5 Replies

8. Shell Programming and Scripting

Perl :: reading values from Data Dumper reference in Perl

Hi all, I have written a perl code and stored the data into Data structure using Data::Dumper module. But not sure how to retreive the data from the Data::Dumper. Eg. Based on the key value( Here CRYPTO-6-IKMP_MODE_FAILURE I should be able to access the internal hash elements(keys) ... (1 Reply)
Discussion started by: scriptscript
1 Replies

9. Shell Programming and Scripting

Perl : reading data from dumper variable

Hi team, # PERL I have Dumper variable in perl and containing the below data and trying to fetch value and name from the reference variable. $VAR1 = { 'retainSysIds' => 'true', 'variables' => , 'name' => , ... (4 Replies)
Discussion started by: giridhar276
4 Replies

10. Shell Programming and Scripting

How to embed data instead of reading user input from an array?

Hello, I am running under ubuntu1 14.04 and I have a script which is sending given process names to vanish so that I'd see less output when I run most popular tools like top etc in terminal window. In usual method it works. Whenever I restart the system, I have to enter the same data from... (2 Replies)
Discussion started by: baris35
2 Replies
DBS_DUMPTABDATA(1p)					User Contributed Perl Documentation				       DBS_DUMPTABDATA(1p)

NAME
dbs_dumptabdata - Creates file set with SQL table data DESCRIPTION
dbs_dumptabdata is an utility to create a file set with SQL table data. For each table in the database dbs_dumptabdata calls the appropri- ate dumper utility with the output directed to a file named table.sql in the current directory. dbs_dumptabdata asks for a password if nec- essary. COMMAND LINE PARAMETERS
Required command line parameters are the DBI driver ("Pg" for Postgres or "mysql" for MySQL) and the database name. The third parameter is optionally and specifies the database user and/or the host where the database resides ("racke", "racke@linuxia.de" or "@linuxia.de"). COMMAND LINE OPTIONS
-t TABLE[,TABLE,...], --tables=TABLE[,TABLE,...] Comma-separated list of tables to dump. --exclude-matching-tables=REGEXP Excludes any table matching the regular expression REGEXP from dumping. --use-printtab Uses generic dump (similar to "dbs_printtab") instead of the dumper utility provided by the DBMS. BUGS
msql is not supported. AUTHOR
Stefan Hornburg (Racke), racke@linuxia.de SEE ALSO
perl(1), DBIx::Easy(3) perl v5.8.8 2007-02-01 DBS_DUMPTABDATA(1p)
All times are GMT -4. The time now is 12:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy