in reply to frequency strings 2 files
Assignments are given to 'rob in' what you have been taught or to provoke you to read more or reserach further, asking questions.
I will give a working code (one of the several ways), but with some lines replaced with comments. Find, understand and fill in the blank spaces and you have your assignment answered.
In addition to this, in place of using Data::Dumper module with the print function to output your answer, you will have to write out your own print output.#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my ( ____, ____ ) = @ARGV; ## get the filenames from the CLI my %number_freq; ## declare an hash to use open my $fh, '<', $file2 or die "can't open cos:$!"; while (<$fh>) { chomp; next if $_ == 0; ## Using each value read from file handler as an hash key, initial +ize the hash value for ## each key to 0 __________________________________________; } close $fh or die "can't close: $!"; open $fh, '<', $file1 or die "can't open cos:$!"; while (<___>) { ## fill in this chomp; next if $_ == 0; ## If the hash key exists increase it's value by 1. __________________________________________; } close $fh or die "can't close: $!"; print Dumper \%number_freq; ## used to display the result
|
|---|