2008/1/22, Jeff Pang <[EMAIL PROTECTED]>:
>
>
>
> -----Original Message-----
> >From: Jenda Krynicky <[EMAIL PROTECTED]>
> >Sent: Jan 23, 2008 12:59 AM
> >To: beginners-list <beginners@perl.org>
> >Subject: Re: about the dot
> >
> >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.
> >
>
> Ok thanks.
> But how about this case? why it can't work as we think?
>
> $ perl -le 'print 3.4 .3. 4'
> Number found where operator expected at -e line 1, near "3. 4"
>         (Missing operator before  4?)
> syntax error at -e line 1, near "3. 4"
> Execution of -e aborted due to compilation errors.
>
>
> and why this can work?
>
> $ perl -le 'print 3.4 .3 .4'
> 3.434
>
>
> in the first case, what rules let perl think the last dot is not an
> operator but a part of the float?
>
> Regards,
> Jeff Pang
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/



Hi

3.4 is a numbre in the c style or native floating point numbers but .3 .4
not in these cases are operator . (dot) and 3 (character '3')

more of this on perlnumber
cheers

Reply via email to