[bcn-pm] manipular un fitxer canviant xifres negatives per un zero

Stanislav web.perldev a gmail.com
dll mar 17 05:53:49 PDT 2014


Hello, Xavier,

Sure, your notes about int() are absolutely correct.
Seems like I was not attentive enough and have not seen that the input file
assumed to be well formed, therefore used this function only for checking
rows for an integer values.

Best regards, Stanislav



2014-03-17 16:36 GMT+04:00 Xavier Noria <fxn at hashref.com>:

> On Mon, Mar 17, 2014 at 1:28 PM, Stanislav <web.perldev at gmail.com> wrote:
>
> Hello, Enric,
>>
>> In this code int() just checks each row of the input file for an integer
>> value.
>>
>
> It does not!
>
>     fxn at yeager:~/tmp $ perl -le 'print int "0"'
>     0
>
>     fxn at yeager:~/tmp $ perl -le 'print int "21.34"'
>     21
>
> int() serves a different purpose (the one explained in its docs).
>
> You need no int() call. Firts, the input file is assumed to be formed by
> numbers. And if you needed to check whether the numbers were well-formed
> you wouldn't use int().
>
> Perl ony has scalar values, if you are thinking numbers vs strings you are
> doing it wrong.
>
> _______________________________________________
> llista dels Barcelona-pm
> Barcelona-pm at pm.org
> http://mail.pm.org/mailman/listinfo/barcelona-pm
> BCN Perl Mongers: http://barcelona.pm.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/barcelona-pm/attachments/20140317/3054dbcd/attachment-0001.html>


Més informació sobre la llista de correu Barcelona-pm