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

Xavier Noria fxn a hashref.com
dll mar 17 05:36:28 PDT 2014


On Mon, Mar 17, 2014 at 1:28 PM, Stanislav <web.perldev a 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 a yeager:~/tmp $ perl -le 'print int "0"'
    0

    fxn a 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.
-------------- part següent --------------
Un document HTML ha estat eliminat...
URL: <http://mail.pm.org/pipermail/barcelona-pm/attachments/20140317/932b6f08/attachment.html>


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