Example 4-8. examples/arrays/process_csv_file.csv
Foo,Bar,10,home Orgo,Morgo,7,away Big,Shrek,100,US Small,Fiona,9,tower
Example 4-9. examples/arrays/process_csv_file.p6
#!/usr/bin/perl6
my $file = 'process_csv_file.csv';
if (defined @*ARGS[0]) {
$file = @*ARGS[0];
}
my $sum = 0;
my $data = open($file, :r) err die "Could not open '$file'\n";
for =$data -> $line {
my @columns = split ",", $line;
$sum += @columns[2];
}
print "$sum\n";
| Prev | Home (Copyright Gabor Szabo) Perl Training Israel | Next |
| Command line options | Up | join |