Q1 What's output by this Perl code? |^| ||| @days = ("Partridges","Turtle Doves","French Hens","Calling Birds"); ||| ($one) = @days; ||| $two = @days; ||| print "$two $one\n";|v| A+ 4 partridges B- (Partridges,Turtle Doves,French Hens,Calling Birds) PartridgesTurtle DovesFrench HensCalling Birds C- PartridgesTurtle DovesFrench HensCalling Birds PartridgesTurtle DovesFrench HensCalling Birds D- PartridgesTurtle DovesFrench HensCalling Birds E- Partridges Turtle Doves French Hens Calling Birds F- An error message Q2 Which of these is a variable name that you should not use? A+ $b B- $d C- $do D- $f E- $if F- $fi Q3 Which of these is incorrect syntax? A- if ($n == 1) { print "Just one in stock\n"; } B- $n == 1 and print "Just one in stock\n"; C- print "Just one in stock\n" if ($n==1); D+ if ($n == 1) print "Just one in stock\n"; E- ($n == 1) && print "Just one in stock\n"; Q4 Which of these is not a correct statement? A- Using a my variable supresses errors if you're using strict B- My variables limit the reach of a variable's name to the block in which they're declared C- It's good practise to declare almost all variables as my D+ My declarations only make a difference if you're using strict Q5 How many times does this code print out "Hello friend"? |^| ||| $name = "Graham"; ||| if ($name == "Lisa") { print "Hello friend\n"; } ||| if ($name eq "Lisa") { print "Hello friend\n"; } ||| if ($name ~~ "Lisa") { print "Hello friend\n"; } ||| if ($name = "Lisa") { print "Hello friend\n"; } ||| if ($name =~ /Lisa/) { print "Hello friend\n"; } |v| A- 0 B- 1 C- 2 D+ 3 E- 4 F- 5 Q6 What will this print out? |^| ||| open source,"railstats.xyz"; ||| @data = ; ||| print $#data+1,"\n"; |v| A+ 0 if the file railstats.xyz can't be read, otherwise the number of lines in the file B- 1 if the file railstats.xyz can't be read, otherwise the number of lines in the file C- an error message if the file railstats.xyz can't be read, otherwise the number of lines in the file D- an error message if the file railstats.xyz can't be read, otherwise the first line in the file E- an error message if the file railstats.xyz can't be read, otherwise the second line in the file Q7 What is the difference between these statements: |^| ||| die ("Unable to read file"); ||| die ("Unable to read file\n"); |v| A- The first one doesn't print a new line at the end of the message, but the second one does B- They produce identical output as die adds a new line if you don't supply one C+ The first one tells you the line number your code failed on (and other debug info), the second does not. Q8 What might the following command line generate? |^| ||| perl -na -F'\t' -e 'print "$F[2], " if /Farnborough/' railstats.xyz |v| A- syntax error at -e line 1, at EOF; Execution of -e aborted due to compilation errors. B- aa C- Farnborough North Farnborough (Main) D+ GU14 2PL, GU14 7NL, Q9 In a Perl regular expression, "p*" means A- match one or more p's B+ match zero or more p's C- match zero or one p D- match p followed by anything E- match p followed by a * QA Which of these will NOT print "10kgs"? A+ $k = 10; print "$kkgs\n"; B- $k = 10; print "${k}kgs\n"; C- $k = 10; print $k."kgs\n"; D- $k = 10; print $k,"kgs\n"; QB How have you found these questions? Your answer to this question will help YOU to decide whether you should join the Perl course for the lead in day that covers the fundamentals, or start with the quick reminder of the basics on the second morning. A+ I found them all straightforward; most of the answers were obvious to me. B+ They were mostly quite easy, but a few got me thinking / used things I hadn't come across C+ I knew some, but others were a struggle. D+ A few were clear to me, but most of them were headscratchers. E+ I found that I had to make far too many guesses for my liking ...