IT 441: Network Services Administration
Class #11 Exercise

Complete by: 4/4/2018


Log in to users.cs.umb.edu

Hash operations

perl>  %ipMac = ('192.168.124.1', '2a:09:4e:3c:31:42', '192.168.124.2', '0e:88:4e:2a:56:07', '192.168.124.3', '1a:32:6f:5c:6b:1a');

perl>  print %ipMac;

perl>  print $ipMac{'192.168.124.1'};

perl>  print $ipMac{'192.168.124.2'};

perl>  print $ipMac{'192.168.124.3'};

perl>  $newIP = '192.168.124.4';

perl>  $ipMac{$newIP} = '2a:09:4e:2a:56:07';

perl>  print "IP $newIP has the MAC: $ipMac{$newIP}";

perl>  @ipMacKeys = keys(%ipMac);

perl>  foreach $k (@ipMacKeys) { print "$k\n" ;}

perl>  foreach $k (@ipMacKeys) { print "$k : $ipMac{$k}\n" ;}

perl>  @ipMacValues = values(%ipMac);

perl>  foreach $v (@ipMacValues) { print "$v\n" ;}

perl>  delete $ipMac{'192.168.124.2'};

perl>  @ipMacKeys = keys(%ipMac);

perl>  foreach $k (@ipMacKeys) { print "$k : $ipMac{$k}\n" ;}

perl>  $ipMac{'192.168.124.1'} = 'foo';

perl>  $ipMac{'192.168.124.4'} = 'bar';

perl>  foreach $k (@ipMacKeys) { print "$k : $ipMac{$k}\n" ; }

(Before closing your perlsession, experiment some with hashes to see what they will do...
In other words, make up some Perl code, similar to what you see above, but different enough to involve other aspects of hashes not covered here...
I will be looking for this.
)

End the Perl Session

perl>  exit

End the script session

Use the exit command. You should then have a file called typescript in your current working directory.