very strange behaviour

Discussion in 'Perl Misc' started by fedeabascal@yahoo.es, Nov 24, 2005.

  1. Guest

    Dear all,

    I'm finding a very strange behaviour of perl when trying to print
    something. Look at this code:

    print " Number of informative (entropy < ",$fields{'ENTROPY'}," and
    gaps < ",$fields{'GAPS'},") columns : $ok_columns\n",
    print " Number of columns considered poorly informative
    : ", scalar(keys(%discarded_columns)), "\n";

    The result is that the second "print" prints before the first "print".
    Always. Look at the output:


    Number of columns considered poorly informative : 33
    Number of informative (entropy < 4.2 and gaps < 0.2) columns : 214
    1


    Additionally, after both "prints" are printed a newline with just a "1"
    is printed.

    Both things happen with different operative systems. If I replace both
    lines with:

    print "hello\n";
    print "bye\n";

    then, everything works as expected. The output is:

    hello
    bye


    I can't imagine why this happens!!

    Best,
    Federico
    , Nov 24, 2005
    #1
    1. Advertising

  2. Guest

    je,je,je... I've been trying to solve this error for long time having
    some headache and now, just when I send it to the group I have noticed
    what was the problem. If you would like to find yourself do not
    continue reading. The solution is.....

    ....


    .....


    .....

    After the first print there is not a semicolon (";") but a comma (",").

    Federico
    , Nov 24, 2005
    #2
    1. Advertising

  3. Anno Siegel Guest

    <> wrote in comp.lang.perl.misc:
    > je,je,je... I've been trying to solve this error for long time having
    > some headache and now, just when I send it to the group I have noticed
    > what was the problem. If you would like to find yourself do not
    > continue reading. The solution is.....
    >
    > ...
    >
    >
    > ....
    >
    >
    > ....
    >
    > After the first print there is not a semicolon (";") but a comma (",").


    The way your code is formatted makes the mistake specially hard to
    spot.

    print " Number of informative (entropy < ",$fields{'ENTROPY'}," and
    gaps < ",$fields{'GAPS'},") columns : $ok_columns\n",
    print " Number of columns considered poorly informative
    : ", scalar(keys(%discarded_columns)), "\n";

    Use white space for indentation and otherwise to make clear
    where each print statement and each of its parameters begin and end:


    print " Number of informative (entropy < ",
    $fields{'ENTROPY'},
    " and gaps < ",
    $fields{'GAPS'},
    ") columns : $ok_columns\n",

    print " Number of columns considered poorly informative : ",
    scalar(keys(%discarded_columns)),
    "\n";

    That takes a few more lines, but now the misplaced comma stands
    out like a sore thumb. That is why proper formatting is important
    in programming. It's not just because it looks nicer, though that's
    a valid reason too.

    Anno
    --
    If you want to post a followup via groups.google.com, don't use
    the broken "Reply" link at the bottom of the article. Click on
    "show options" at the top of the article, then click on the
    "Reply" at the bottom of the article headers.
    Anno Siegel, Nov 24, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    451
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,592
    Merrill & Michele
    Oct 19, 2004
  3. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    409
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    498
    Dave Thompson
    Feb 14, 2005
  5. Sunjay Varma
    Replies:
    4
    Views:
    329
    John Roth
    Mar 10, 2011
Loading...

Share This Page