Overview: Arrays in perl
You have been using arrays in perl for some weeks now, however all of these arrayshave been populated by calling a function from Text::CSV. We have not modified thecontents of the array ourselves.
You can add elements to an array in perl using the push function.
For example, the following code creates an empty array, and then adds two valuesto it: sub printArrayContents {
Lab5/CIS*2250 # placemy @array_argument = @_;the f i r s t argument into the variable @array_argument
Determining Unique Values i f ( $#array_argument >= 0 ) {
m courselink.uoguelph.ca i A. Hamilton-Wright &K. Raymond Overview
Learning objectives:
fieldssetsof values Extracting and examining#H Dealing with large data# Managing lists
Skills
coordination + communication (3/6) organization + planning (3/6) teamwork (3/6) programming + tools (5/6) strategy (3/6) visualization (0/6)
print Array has . $#array_argument . values :
;
foreach my $iprint
} else} $array_argument [ $i ]Value(0 . . $#array_argument ). $i . is .
;. {
} } print{ Array is empty
; my @list_of_values ;
printArrayContents ( @list_of_values ) ; push( @list_of_values ,printArrayContents ( @list_of_values ) ;one ); push( @list_of_values ,printArrayContents ( @list_of_values ) ;two );
Note thethe order of any of the other values.push function adds the new value to the end of the array, without disturbing
Task 1 Description: Collecting Unique Values
will work as follows:For this lab, you are asked to write a program printUniqueColumnValues.pl that
- it will take as arguments the name of a csv file to process, and a column to
(*)[tal Awareness) to 6 (Main Focus).]The skill scale is from 0 (Fundamen- examine, for example:perl printUniqueColumnValues.pl WorldBank_EducationData.csv 2 Image descriptionA pair of work socks. Image sourcefreebie.photography CC BY 3.0 in the column of data within the .csv file, a list is collected of any value not yetseenat the end, this list is printed.
This will provide a summary of what the values are within a given column of datain the file. scribes rates of education around the world.You will find the WorldBank_EducationData.csv file on CourseLink. This file deIf the file is run as in the example above:
then the expected output is this:perl printUniqueColumnValues.pl WorldBank_EducationData.csv 2
Overview
AdjustedAdjustedAdjustedAdjustedAdjustedAdjustedAdjustedAdjustedAdjustedSeries netnetnetnetnetnetnetnetnet enrolmentenrolmentenrolmentenrolmentenrolmentenrolmentintakeintakeintakepopulation , 15+ years , % femalepopulation , 15+ years ,population , 15+ years ,raterateraterate ,rate ,rate ,rate ,rate ,rate ,rate ,to Grade 1 ofto Grade 1 ofto Grade 1 ofupper secondary ,upper secondary ,upper secondary ,primary ,primary ,primary ,lowerlower secondary ,secondary ,secondary ,male (%)both sexes (%)female (%)primaryprimaryprimarymaleboth sexesfemale(numbermale (%)male (%)both sexes (%)both sexes (%)female (%)female (%)education ,education ,education ,(number(number) ) male (%)both sexes (%)female (%))
AdjustedAdjustedAdult i l l i t e r a t ei l l i t e r a t ei l l i t e r a t enet enrolmentenrolment rate ,rate , lower AdultAdult
AdjustedAdult i l l i t e r a t enetnet enrolmentpopulation , 15+ years ,
fieldssetsof values Extracting and examining#H Dealing with large data# Managing lists Be sure to upload your printUniqueColumnValues.pl to CourseLink. Learning objectives:
Skills
coordination + communication (3/6) organization + planning (3/6) teamwork (3/6) programming + tools (5/6)
strategy (3/6) visualization (0/6)
(*)[tal Awareness) to 6 (Main Focus).]The skill scale is from 0 (Fundamen-
Image description
A pair of work socks. Image sourcefreebie.photography CC BY 3.0
Reviews
There are no reviews yet.