[Edinburgh-pm] Ingorance

Ian Stuart Ian.Stuart at ed.ac.uk
Wed Mar 7 06:49:16 PST 2007

Andrew Smith wrote:
> Hi guys
> I was playing around with the attached test program  and don't 
> understand why line 8 doesn't prints *"1* rather  *"1 2 3"* for the 
> value $words[1], and just *2* for $words1[2] rather than *def*.
> as it does when printing the full array.  I think I understand that *qw* 
> puts single *'* around space delimited words which is why the double *"* 
> get included in  element 1.
> I've probably forgotten something fundamental, so your replies don't 
> have to be kind to my feelings.
Well, my first guess would be that the qw is splitting on white space, 
but that Perl is smart enough to know that "1 2 3" is a complete string, 
not three items: *"1*, *2*, & *3"*

Aha... P 63, Camel book, 3rd edition: "If the opening delimiter is an 
opening parenthesis, bracket, brace, or angle bracket, the closing 
delimiter will be the corresponding closing character.  (Embedded 
occurrences of the delimiters must match in pairs.)"

I would take that to mean that "1 2 3" is a string, using the delimiter *"*


Ian Stuart.
Bibliographics and Multimedia Service Delivery team,
The University of Edinburgh.


More information about the Edinburgh-pm mailing list