On Tue, Dec 9, 2008 at 16:04, Mr. Shawn H. Corey <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-12-09 at 15:55 -0500, David Shere wrote:
>> On Tue, 2008-12-09 at 15:51 -0500, Mr. Shawn H. Corey wrote:
>> > print '', (split( /\./, $ipAddress ))[-1];
>>
>> Thanks.  I was searching for about an hour before I posted here; I found
>> an answer online a few minutes later:
>>
>> http://www.perlmonks.org/?node_id=299283
>>
>> Curious:  What's the '', for?  Scalar context?
>
> So print won't that the first parenthesis as part of its function.  An
> alternative is:
>
> print ((split( /\./, $ipAddress ))[-1]);
>
> See `perldoc -f print` for details.
snip

The canonical way of telling a function that the parenthesis the
follow do not belong to it is to use unary +:

print +(1,2,3,4)[-1], "\n";

from http://perldoc.perl.org/perlop.html#Symbolic-Unary-Operators
       Unary "+" has no effect whatsoever, even on strings.  It is useful
       syntactically for separating a function name from a parenthesized
       expression that would otherwise be interpreted as the complete list of
       function arguments.  (See examples above under "Terms and List
       Operators (Leftward)".)

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to