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. Advertisements

  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. Advertisements

  3. Guest

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

    Federico
     
    , Nov 24, 2005
    #3
    1. Advertisements

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. Jan
    Replies:
    2
    Views:
    1,701
    Mike Treseler
    Dec 16, 2004
  2. 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:
    725
    Raymond Hettinger
    Jul 27, 2003
  3. Syver Enstad

    Very strange unicode behaviour

    Syver Enstad, Jan 16, 2004, in forum: Python
    Replies:
    5
    Views:
    488
    Erik Max Francis
    Jan 16, 2004
  4. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    2,055
    Merrill & Michele
    Oct 19, 2004
  5. Abhishek Jha

    very very very long integer

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

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    817
    Dave Thompson
    Feb 14, 2005
  7. olivier.melcher

    Help running a very very very simple code

    olivier.melcher, May 12, 2008, in forum: Java
    Replies:
    8
    Views:
    2,788
  8. Sunjay Varma
    Replies:
    4
    Views:
    554
    John Roth
    Mar 10, 2011
Loading...