oysters2000
Programmer
Hi expert
I will be writing my exam next week and need some explaining on the following:
1. I need help with the following code, if possible. could you please explain how they work out the 2nd print of the string, and what does $1 stand for. I have the answer but just checking if there are other solutions.
$str ="A fox in a box trading socks";
$str =~m/..(...)../;
print ("$1 ");
$str =~m/\s+$1.in\sa\s[a-d]{1}(\w{2}); # this part i don’t understand(how do they get “ox”)
print "$1 ";
$str =~m/([stock]{6});
print "$1 ";
2. in the pre-assements of the hash’s, the second question I don’t understand how they get their answer of 52?
%hash = (1=>2
2 =>3
3 =>4);
$hash{2} = 5;
$hash = 6;
%hash = reverse(%hash);
for ($i = 1; $i < 5; $i++)
{
delete($hash{$1});
}
print(%hash)
If you could get back to I would appreciate it.
Regards mark