Perl, PHP, Python, Ruby, Lua, C, C++, Tcl
Open Source Programming Training

Home Page - http://www.wellho.net
Public courses at Well House Manor
Private courses at your offices

Article on how to read your results

Test your current Perl knowledge ...


A short test to see where you should start ...

This test has been prepared for one of our customers, who's arranging a Perl course that will run for 3 days; its purpose is to help delegates decide if they should start on the first day of the course we'll be running there, or at the revision section at the start of the second day of their course. There is no time limit for this test. However, we do note the time you have taken, and would be concerned if you took a long time.

The test will also give others a good feel as to whether they know the basics of Perl well - a helpful assessment to aid the selection of training. We request your name and email address simply so that we can correlate the results and refer back to your answers should you get in touch with us. You will not be added to any databases. Written and hosted by Well House Consultants - contact details at base of page. This page does NOT use cookies.

Name
email
 
Question 1: What's output by this Perl code?

      @days = ("Partridges","Turtle Doves","French Hens","Calling Birds");
      ($one) = @days;
      $two = @days;
      print "$two $one\n";


   4 partridges
   (Partridges,Turtle Doves,French Hens,Calling Birds) PartridgesTurtle DovesFrench HensCalling Birds
   PartridgesTurtle DovesFrench HensCalling Birds PartridgesTurtle DovesFrench HensCalling Birds
   PartridgesTurtle DovesFrench HensCalling Birds
   Partridges Turtle Doves French Hens Calling Birds
   An error message
 
Question 2: Which of these is a variable name that you should not use?
   $b
   $d
   $do
   $f
   $if
   $fi
 
Question 3: Which of these is incorrect syntax?
   if ($n == 1) { print "Just one in stock\n"; }
   $n == 1 and print "Just one in stock\n";
   print "Just one in stock\n" if ($n==1);
   if ($n == 1) print "Just one in stock\n";
   ($n == 1) && print "Just one in stock\n";
 
Question 4: Which of these is not a correct statement?
   Using a my variable supresses errors if you're using strict
   My variables limit the reach of a variable's name to the block in which they're declared
   It's good practise to declare almost all variables as my
   My declarations only make a difference if you're using strict
 
Question 5: 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"; }


   0
   1
   2
   3
   4
   5
 
Question 6: What will this print out?

      open source,"railstats.xyz";
      @data = <source>;
      print $#data+1,"\n";


   0 if the file railstats.xyz can't be read, otherwise the number of lines in the file
   1 if the file railstats.xyz can't be read, otherwise the number of lines in the file
   an error message if the file railstats.xyz can't be read, otherwise the number of lines in the file
   an error message if the file railstats.xyz can't be read, otherwise the first line in the file
   an error message if the file railstats.xyz can't be read, otherwise the second line in the file
 
Question 7: What is the difference between these statements:

      die ("Unable to read file");
      die ("Unable to read file\n");


   The first one doesn't print a new line at the end of the message, but the second one does
   They produce identical output as die adds a new line if you don't supply one
   The first one tells you the line number your code failed on (and other debug info), the second does not.
 
Question 8: What might the following command line generate?

      perl -na -F'\t' -e 'print "$F[2], " if /Farnborough/' railstats.xyz


   syntax error at -e line 1, at EOF; Execution of -e aborted due to compilation errors.
   aa
   Farnborough North Farnborough (Main)
   GU14 2PL, GU14 7NL,
 
Question 9: In a Perl regular expression, "p*" means
   match one or more p's
   match zero or more p's
   match zero or one p
   match p followed by anything
   match p followed by a *
 
Question A: Which of these will NOT print "10kgs"?
   $k = 10; print "$kkgs\n";
   $k = 10; print "${k}kgs\n";
   $k = 10; print $k."kgs\n";
   $k = 10; print $k,"kgs\n";
 
Question B: 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.
   I found them all straightforward; most of the answers were obvious to me.
   They were mostly quite easy, but a few got me thinking / used things I hadn't come across
   I knew some, but others were a struggle.
   A few were clear to me, but most of them were headscratchers.
   I found that I had to make far too many guesses for my liking ...
 
When done, please

Set by Well House Consultants

Training sample © 2022, WELL HOUSE CONSULTANTS LTD
This is http://www.wellho.net/demo/qua.php
Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
Phone: +44 (0) 1225 708 225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net