<?xml version="1.0" encoding="windows-1252"?>
<node id="72671" title="NEWBIE Brain Teaser #2, by nysus" created="2001-04-15 16:36:54" updated="2005-08-13 03:41:32">
<type id="115">
perlquestion</type>
<author id="66801">
nysus</author>
<data>
<field name="doctext">
&lt;!-- edited by chipmunk: encoded ampersand --&gt;

This is designed to test your knowledge of how arguments get passed to subroutines.&lt;p&gt;

&lt;b&gt;Instructions for Newbies:&lt;/b&gt;
&lt;p&gt;
&lt;i&gt;Part A&lt;/i&gt;&lt;br&gt;
What do you think the output of the code below is?&lt;p&gt;
&lt;i&gt;Part B&lt;/i&gt;&lt;br&gt;
Give an accurate explanation for your answer.&lt;p&gt;
&lt;i&gt;Part C&lt;/i&gt;&lt;br&gt;
What happens when you replace "subroutine ();" in line 7 with "&amp;amp;subroutine;"?  Why?&lt;p&gt;
&lt;b&gt;Instructions for Non-Newbies:&lt;/b&gt;&lt;p&gt;
I'm not going to provide an immediate solution or explanation for this one.  Feel free to drop hints and provide general guidance as you see fit.&lt;p&gt;
&lt;b&gt;The Code&lt;/b&gt;
&lt;code&gt;
1  #!/usr/bin/perl
2
3  use strict;
4
5  @_ = qw(alpha omega);
6  $_ = qw(nothing nothing);
7  subroutine ();
8 
9  sub subroutine {
10 	print "In the beginning there was $_[0], in the end there will be $_[1].\n";
11 }
&lt;/code&gt;

&lt;p&gt;&lt;small&gt;&lt;b&gt;Edit&lt;/b&gt;: chipmunk 2001-04-16&lt;/small&gt;&lt;/p&gt;</field>
</data>
</node>
