On 08 Jun 2001 11:42:34 -0400, Chas Owens wrote:
> On 08 Jun 2001 10:31:25 -0500, [EMAIL PROTECTED] wrote:
> > The code is below; what's pertinent is really the last line.
> > When I drop the ."\n" the hash prints as expected, but with no line breaks
> > between records. Assuming concactenating the \n would do it, I threw it into
> > the print command.
> > Now it returns a value of 2/8 instead of the hash values. . . what's the
> > deal here? 
> <snip>
> > print %cs."\n";
> 
> Order of operations is happening here.  The concat (.) operator has a
> higher 
> precedence than system calls (ie print).  Try using (,) instead:
> 
> print %cs, "\n";

I just realized I didn't explain anything here.

print %cs;

works because %cs is in a list context therefore it dumps the key/value 
pairs as a list to print.

print %cs . "\n";

doesn't work because order of operations makes it look like this:

print( (%cs . "\n") );

%cs . "\n" is evaluated first, since . has a scalar context %cs is 
treated as the scalar "2/8" (number of used buckets/number of 
allocated buckets) and the concat makes it "2/8\n".  Then the print
happens.

print %cs, "\n";

works because the (,) operator just appends "\n" onto the list created
by putting %cs in a list context. 

--
Today is Prickle-Prickle, the 13rd day of Confusion in the YOLD 3167
All Hail Discordia!


Reply via email to