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

Agud Pique, Enric eagud.q a tv3.cat
dll mar 17 05:47:16 PDT 2014


Thank you again

Best

Enric
________________________________
De: Barcelona-pm [barcelona-pm-bounces+eagud.q=tv3.cat a pm.org] en nom de Xavier Noria [fxn a hashref.com]
Enviat el: dilluns, 17 / març / 2014 13:36
Per a: Barcelona Perl Mongers
Tema: Re: [bcn-pm] manipular un fitxer canviant xifres negatives per un zero

On Mon, Mar 17, 2014 at 1:28 PM, Stanislav <web.perldev a gmail.com<mailto: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.


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