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

I would take it for guaranted that you had asked for in perl :slight_smile:

#! /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

thanks a lot