Weird Error message

Discussion in 'Perl Misc' started by phaylon, Feb 15, 2005.

  1. phaylon

    phaylon Guest

    Christoph Sünderhauf wrote:

    > print "$termine[($line + 1 )] \n\n";


    Do you want

    print $termine[ $line + 1 ]."\n\n";

    ? You may want to read upon interpolation.

    hth,phay

    --
    http://www.dunkelheit.at/

    The first rule of project mayhem is: you do not ask questions.
    -- Fight Club
    phaylon, Feb 15, 2005
    #1
    1. Advertising

  2. Use of uninitialized value in concatenation (.) or string at start.pl
    line 54.


    Does someone know what this means?
    line 54 is:

    print "$termine[($line + 1 )] \n\n";
    Christoph Sünderhauf, Feb 15, 2005
    #2
    1. Advertising

  3. phaylon

    phaylon Guest

    Anno Siegel wrote:

    > What about it? The interpolation is fine.


    Hum, maybe I got misleaded by my reading, but I thought the op tried to
    print the $line'th + 1 element of $termine. Is interpolation the wrong
    term for interpreted symbols (functions, vars) in quoted strings? If so, I
    would thank you for clearing me up.

    g,phay

    --
    http://www.dunkelheit.at/

    The eternal mistake of mankind is to set up an attainable ideal.
    -- Aleister Crowley
    phaylon, Feb 15, 2005
    #3
  4. phaylon

    Anno Siegel Guest

    phaylon <> wrote in comp.lang.perl.misc:
    > Christoph Sünderhauf wrote:
    >
    > > print "$termine[($line + 1 )] \n\n";

    >
    > Do you want
    >
    > print $termine[ $line + 1 ]."\n\n";
    >
    > ? You may want to read upon interpolation.


    What about it? The interpolation is fine.

    Whatever $line contained at the moment, $termine[ $line + 1] was undefined,
    that's all.

    The message (a warning, not an error message)

    "Use of uninitialized value in concatenation (.) or string..."

    is very common and hardly weird. It describes exactly what happened.

    Anno
    Anno Siegel, Feb 15, 2005
    #4
  5. thank you, thats just what I needed.
    But what is interpolation?
    Christoph Sünderhauf, Feb 15, 2005
    #5
  6. Christoph Sünderhauf wrote:
    >
    > Use of uninitialized value in concatenation (.) or string at start.pl
    > line 54.
    >
    > Does someone know what this means?
    > line 54 is:
    >
    > print "$termine[($line + 1 )] \n\n";


    It means that the array element you try to print either doesn't exist or
    is undefined. When you include a variable together with other stuff
    between doublequotes, you concatenate the variable value with the other
    stuff into a string. The above is the same as:

    print $termine[($line + 1 )] . " \n\n";

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 15, 2005
    #6
  7. phaylon

    Tony Curtis Guest

    >> On Tue, 15 Feb 2005 20:29:30 +0100,
    >> Christoph Sünderhauf <> said:


    > I have another Question: when you use \n with print, you get
    > a new line. Is there something that makes print continue to
    > write on the same line?


    Don't print \n ... ???

    You've got to mean something else though, surely?
    Tony Curtis, Feb 15, 2005
    #7
  8. Christoph Sünderhauf wrote:
    > phaylon wrote:
    >> Christoph Sünderhauf wrote:
    >>>
    >>> Use of uninitialized value in concatenation (.) or string at start.pl
    >>> line 54.
    >>>
    >>> Does someone know what this means?
    >>> line 54 is:
    >>>
    >>> print "$termine[($line + 1 )] \n\n";

    >>
    >> Do you want
    >>
    >> print $termine[ $line + 1 ]."\n\n";

    >
    > thank you, thats just what I needed.


    Could somebody possibly explain the expected difference with respect to
    the above warning?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 15, 2005
    #8
  9. I have another Question:

    when you use \n with print, you get a new line.
    Is there something that makes print continue to write on the same line?
    Christoph Sünderhauf, Feb 15, 2005
    #9
  10. Christoph Sünderhauf wrote:
    > I have another Question:


    Then it would have been appropriate to start a new thread with a new
    subject line.

    > when you use \n with print, you get a new line.


    \n represents a newline in Perl whether used in a print() statement or
    elsewhere.

    > Is there something that makes print continue to write on the same line?


    Don't print newlines...?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 15, 2005
    #10

  11. > You've got to mean something else though, surely?


    Youre right, I meen that it erases the thing before:

    I want to print the time
    and then I want to replace the time with the new one.


    Is there any way to do this?
    Christoph Sünderhauf, Feb 15, 2005
    #11
  12. phaylon

    Anno Siegel Guest

    phaylon <> wrote in comp.lang.perl.misc:
    > Anno Siegel wrote:
    >
    > > What about it? The interpolation is fine.

    >
    > Hum, maybe I got misleaded by my reading, but I thought the op tried to
    > print the $line'th + 1 element of $termine. Is interpolation the wrong
    > term for interpreted symbols (functions, vars) in quoted strings? If so, I
    > would thank you for clearing me up.


    Have you tested the OPs code with appropriately set up @termine and $line?
    It works as expected.

    Once interpolation is triggered by "$" or "@", anything goes. In particular,
    the index in "$array[ ...]" can be any Perl expression, including "$line +
    1". This is how interpolation of arbitrary expressions can be enforced
    (or simulated, if you prefer):

    "string @{ [ lc $obj->meth] } more string"

    is a common, though not very popular idiom.

    Anno
    Anno Siegel, Feb 15, 2005
    #12
  13. phaylon

    Anno Siegel Guest

    Christoph Sünderhauf <> wrote in comp.lang.perl.misc:
    >
    > > You've got to mean something else though, surely?

    >
    > Youre right, I meen that it erases the thing before:


    If you're printing to a screen, you may want "\r", but the exact effect
    would depend on your system and the terminal emulation you're running.

    If you're printing to a file, there is no character code to overwrite a
    line already written.

    Anno
    Anno Siegel, Feb 15, 2005
    #13
  14. Christoph Sünderhauf wrote:
    > Youre right, I meen that it erases the thing before:
    >
    > I want to print the time
    > and then I want to replace the time with the new one.


    local $| = 1;
    print 'Hello!';
    sleep 3;
    print "\015", "Good-bye!\n";;

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Feb 15, 2005
    #14
  15. Christoph Sünderhauf wrote:

    >
    >
    > Use of uninitialized value in concatenation (.) or string at start.pl
    > line 54.
    >
    >
    > Does someone know what this means?
    > line 54 is:
    >
    > print "$termine[($line + 1 )] \n\n";


    It means either that element ($line + 1) of the array
    @termine is undefined.

    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Feb 15, 2005
    #15
  16. Christoph Sünderhauf wrote:

    > I have another Question:
    >
    > when you use \n with print, you get a new line.
    > Is there something that makes print continue to write on the same line?


    Yes. Don't use \n.
    --
    Christopher Mattern

    "Which one you figure tracked us?"
    "The ugly one, sir."
    "...Could you be more specific?"
    Chris Mattern, Feb 15, 2005
    #16
  17. phaylon

    phaylon Guest

    Anno Siegel wrote:

    > "string @{ [ lc $obj->meth] } more string"
    >
    > is a common, though not very popular idiom.


    Argh, thx, Have to read something in perldoc now ..

    --
    http://www.dunkelheit.at/
    codito, ergo sum.
    phaylon, Feb 16, 2005
    #17
    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. nateastle
    Replies:
    0
    Views:
    392
    nateastle
    Jun 1, 2009
  2. dorayme
    Replies:
    1
    Views:
    602
    richard
    Jan 21, 2011
  3. richard
    Replies:
    0
    Views:
    571
    richard
    Jan 21, 2011
  4. richard
    Replies:
    0
    Views:
    605
    richard
    Jan 21, 2011
  5. Beauregard T. Shagnasty

    Re: A Weird Appearance for a Weird Site

    Beauregard T. Shagnasty, Jan 21, 2011, in forum: HTML
    Replies:
    1
    Views:
    425
    Captain Paralytic
    Jan 21, 2011
Loading...

Share This Page