![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to store the values in a file into an array | risshanth | UNIX for Dummies Questions & Answers | 3 | 01-22-2008 06:34 AM |
| How to read from txt file and use that as an array | pinky | UNIX for Dummies Questions & Answers | 4 | 10-07-2007 09:18 PM |
| create array holding characters from sring then echo array. | rorey_breaker | Shell Programming and Scripting | 5 | 09-28-2007 05:42 AM |
| Dump an array in a file | IMD | Shell Programming and Scripting | 3 | 08-31-2006 07:04 AM |
| File to Array and Back. | Boucho | High Level Programming | 1 | 02-14-2006 07:32 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
From File to Array
Hi all,
I want to store the records from a file to an array. What approach can I use? e.g. soruce_file: aaa bbb ccc array: arr[0]=aaa arr[1]=bbb arr[2]=ccc Thanks, Rock |
| Forum Sponsor | ||
|
|
|
|||
|
I would take it for guaranted that you had asked for in perl
Code:
#! /opt/third-party/bin/perl
open(FILE, "< filename") || die "Unable to open file. <$!>\n";
while( chomp($content = <FILE>) ) {
push(@arr1, $content);
}
#If this needs to be displayed
foreach my $var(@arr1) {
print "$var\n";
}
close(FILE);
exit 0
|