# ****************************************************** # * # * Name: tst-read-text-file.pl # * # * Design Phase: # * Author: John Miner # * Date: 05/10/2012 # * Purpose: A test program to read text files. # * # ****************************************************** # http://community.activestate.com/forum/error-cant-extract-files-ppm-fails-extract-tgz # Declare all variables use strict; # Include defined module (CPAN) use Text::Delimited; # Create instance of module my $file = new Text::Delimited; # Define delimiter $file->delimiter(','); # Open the file $file->open('c:\temp\presidents.csv'); # Read the header my @header = $file->fields; # Show the data while ( my $row = $file->read ) { print $row->{id}, ' - ', "\n"; print " last name = ", $row->{last}, "\n"; print " first name = ", $row->{first}, "\n"; print " address 1 = ", $row->{adress1}, "\n"; print " address 2 = ", $row->{adress2}, "\n"; print " city = ", $row->{city}, "\n"; print " state = ", $row->{state}, "\n"; print " zip = ", $row->{zip}, "\n"; print " term = ", $row->{term}, "\n"; print "\n", "\n"; }