From: Jeff Pang <[EMAIL PROTECTED]> > I'm a little confused by perl's dot operator.for example, > > $ perl -le 'print 3 . 4 ' > 34 > $ perl -le 'print 3.4 ' > 3.4 > > these two commands got different results. > > who says Perl interpreter will ignore the blackspace around an operator? I > saw it doesn't here. > Ok you may say 3.4 is a float not a statement with '.' operation, but this > case really make people confused.
As far as I can tell you are the first to get confused. I mean if the compiler sees a digit it knows a numerical literal starts. So it reads as much as it can that still matches the definition of numberical literal and then looks for an operator or end of statement or end of block or closing brace or ... 3.4 whole matches so it is treated as such. And since spaces are not allowed withing numerical literals as soon as perl encounters a space the literal is considered complete and perl starts to look for the next thing. In either case it is what it looks like. 3.4 looks like a float so it is float. 3 . 4 doesn't look like a single float. It looks like two integers with some operator. And that's what it is. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/