Concepts of Programming Languages, CSCI 305, Fall 2013 Lab 4, perl, Sept. 27

bewgrosseteteSoftware and s/w Development

Dec 13, 2013 (3 years and 3 months ago)

63 views

Concepts of
Programming Languages
,

C
S
CI 305
,

Fall 201
3

Lab

4
,
perl
,

Sept.
2
7


Reference guide:

http://www.math.harvard.edu/computing/perl/perl.pdf




1.

Create a perl

script which displays the contents of a file. You can have the user enter
a file name, or just redirect the file into standard input. (
User the file
RobertFrost.txt.)




2.

Display the poem, except replace mind (case insensitive) with something else.






3.

Display the poem, except remove the most frequently used word.






4.

Perl is particularly good for
scanning large quanti
t
ies of data
,

doing pattern matching
and replacing text. The file ‘FarmRate.csv’ contains data which I would like to be
inserted into a database. Here is the sql statement which created the table for which
the data is to be inserted:


DROP TABLE IF EXISTS `CommoditiesRateTable`;

CREATE TABLE
`CommoditiesRateTable` (


`stateCode` char(2) NOT NULL,


`countyCode` char(3) NOT NULL,


`commodityCode` char(4) NOT NULL,


`coverageLevel` char(2) NOT NULL,


`paymentRate` char(3) NOT NULL,


`wholeFarmRate` char(4) default NULL,


PRIMARY KEY
(`stat
eCode`,`countyCode`,`commodityCode`,`coverageLevel`,`paymentRate`);



Here is a sample sql statement for inserting one row of data

into that table
:


INSERT INTO CommoditiesRateTable (stateCode, countyCode, commodityCode,
coverageLevel, paymentRate
,wholeFarmRate) VALUE (01, 320, 3544, 12, 221,
6554);


Create a perl program which takes the ‘FarmRate.csv’ file and input and outputs a file
containing the insert statements.