Complete the script to create a hash slice which is a hash keys whose correspond
ID: 3705636 • Letter: C
Question
Complete the script to create a hash slice which is a hash keys whose corresponding values are assigned to another list of keys. Assume that you are working on a student records: (25 pts.) xstudent ID 123456789 NAME Robert Smith SSN "518-18-5454 Do5/19/96 )i update auSavannah 9123584788 engineerin gesavannahstate.edu): gnash slice for crTY, PHONE, LMA?L priet the bash-slice 4) Complete the seript to accomplish the following tuasks using Perl built-in fupctions (10pts) %friends-( "Dallas". "Exeter, "Reading Cary Lucy lan Samantha Oregon" Eva Julia "Deven". Tokyp" a) Priot orly the keys from the hashExplanation / Answer
4
#Program in Perl to print keys , values & both from a given hash
my %friends = (
'Gary' => "Dallas",
'Lucy' => "Exeter",
'IAN' => "Reading",
'Samantha' => "Oregon",
'Eva' => "Deven",
'Julie' => "Tokyp"
);
# to print only keys 4(a)
print " keys####### " ;
while( my( $key, $value ) = each %friends ){
print "$key ";
}
# to print only values 4(b)
print " values##### " ;
while( my( $key, $value ) = each %friends ){
print "$value ";
}
# to print both keys and values 4(c)
print " keys:values#### " ;
while( my( $key, $value ) = each %friends ){
print "$key: $value ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.