Mjpaddy has asked for the wisdom of the Perl Monks concerning the following question:
I have a question, how to create array as follows:
input file
1 2 hello aerf 1 2 hello aerf 1 2 hello aerf 1 2 hello aerf 1 2 hello aerf 1 2 hello aerf
$VAR1 = [ ['1,2,\'hello\',\'aerf\''], ['1,2,\'hello\',\'aerf\''], ['1,2,\'hello\',\'aerf\''], ['1,2,\'hello\',\'aerf\''], ['1,2,\'hello\',\'aerf\''], ['1,2,\'hello\',\'aerf\''] ];
Really appreciate any help.
use Data::Dumper; open FH, "sap.txt" or die "$!"; while(<FH>){ chomp $_; push(@data,$_); } print Dumper \@data; close FH; __DATA__ $VAR1 = [ '1 2 hello aerf', '1 2 hello aerf', '1 2 hello aerf', '1 2 hello aerf', '1 2 hello aerf', '1 2 hello aerf' ]; #now how I can convert this into the above output
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to create array from file
by choroba (Cardinal) on Jan 20, 2017 at 12:29 UTC | |
by Mjpaddy (Acolyte) on Jan 20, 2017 at 13:09 UTC | |
by Corion (Patriarch) on Jan 20, 2017 at 13:11 UTC | |
by choroba (Cardinal) on Jan 20, 2017 at 13:35 UTC | |
by AnomalousMonk (Archbishop) on Jan 20, 2017 at 20:02 UTC | |
|
Re: How to create array from file
by Corion (Patriarch) on Jan 20, 2017 at 12:14 UTC | |
by Mjpaddy (Acolyte) on Jan 20, 2017 at 12:25 UTC | |
by Corion (Patriarch) on Jan 20, 2017 at 12:28 UTC |