[ale] Perl monks ?

mailbox1005 at io.oit.gatech.edu mailbox1005 at io.oit.gatech.edu
Wed May 1 15:07:25 EDT 2002


> 1. Is the following snippet a valid piece of Perl code? 
> s/[Tt]he\s/a/gis; 

Yes, ignoring case, it will substitute 'the\s' with the letter 'a' globally
in the '$_' variable.  So something like 'the bat, The ball, thE homerun'
will become 'abat, aball, ahomerun'.  The '[Tt]' is redundant in this case.

> 2. Will the following code open a file named "thefile" for output? 
> open OUT, "thefile"; 

No, it will open 'thefile' for input.

> 3. For the following snippet of code, is array2 created as a reference to
> array1? 
> @array1 = @array2; 

No, it will copy the @array2 array to @array1 element by element.  You'd
need something like $array1= \@array2 to create a reference to array2.

> 4. Does the following snippet of code define a valid hash? 
> %myhash = ("1", "Steve", 
> "2", "Bob", 
> "A", "Frank");  

Yes, $myhash{'1'} is 'Steve', $myhash{'2'} is 'Bob', and $myhash{'A'} is
'Frank'.

-- 
Jerry Swann       "Jerry dot Swann at oit dot gatech dot edu"
Georgia Institute of Technology
Office Phone: 404 894-1659
Office Fax:   404 894-9548

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list