Perl Warts

misfeatures and other problems
PERL| PHP| PYTHON| RUBY
What do each of the following programs do? (all answers)
Question 1: (answer)
#!/usr/bin/perl

foreach $x (1,2,3,4,5) {
  print "x: $x\n";
  if ($x > 2) { print "break\n"; break; }
}
answer
Question 2: (answer)
#!/usr/bin/perl

$x = "moo";
if ($x == "") { print "Please supply input.\n"; }
else { print "You wrote '$x'\n"; }
answer
PERL| PHP| PYTHON| RUBY
Last modified: March 30, 2006 @ 6:47 MST
Copyright (C) 1996-2024 Selene ToyKeeper