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. <> skrev i meddelandet
    news:...
    > 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.

    Youre printing the result of print which is 1
    either do
    print " Number of informative (entropy < ",$fields{'ENTROPY'}," and
    gaps < ",$fields{'GAPS'},") columns : $ok_columns\n" ; # <--- OBS this
    semicolon
    print " Number of columns considered poorly informative
    : ", scalar(keys(%discarded_columns)), "\n";

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

    >
    > 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
    >
    Bengt-Arne Fjellner, Nov 24, 2005
    #2
    1. Advertising

  3. Guest

    Thank you for the keen-eye!! yours is much faster than mine.

    Federico
    , 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:
    456
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,595
    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:
    411
    jacob navia
    Oct 17, 2004
  4. Peter

    Very very very basic question

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

Share This Page