Weird Error message

C

Christoph Sünderhauf

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";
 
P

phaylon

Anno said:
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
 
A

Anno Siegel

phaylon said:
Christoph said:
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
 
G

Gunnar Hjalmarsson

Christoph said:
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";
 
T

Tony Curtis

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?
 
G

Gunnar Hjalmarsson

Christoph said:
phaylon said:
Christoph said:
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?
 
C

Christoph Sünderhauf

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?
 
G

Gunnar Hjalmarsson

Christoph said:
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...?
 
C

Christoph Sünderhauf

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?
 
A

Anno Siegel

phaylon said:
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
 
A

Anno Siegel

Christoph Sünderhauf said:
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
 
G

Gunnar Hjalmarsson

Christoph said:
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";;
 
C

Chris Mattern

Christoph said:
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?"
 
C

Chris Mattern

Christoph 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?

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

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top