Perl - strings vs ints

Soldato
Joined
15 Nov 2008
Posts
5,060
Location
In the ether
Hi,

A quick question about Perl. Say I have the following script:
$a = 2;
$b = 3;
$name = "Fred Blogs\n";
print "Floppy!";
print $name;
print "Floppy2!";
$c = $a+$b;

Now using the debugger I can see that as soon as $a and $b are initialized I can see their values so if I break at line 2 and do
>p $a
==2
I can see that $a has value 2. But if I break at line 4 I can't see anything in $name
>p $name
==
But once $name is used on line 5 I can then see it :/

Is this some sort of dynamic variable scoping so checking at the method what the object is? :confused:
 
I just ran that through eclipse and it shows $name getting assigned at line 3, and can print it. Also tried in ddd and it produces the same result.

What debugger are you using?
 
I just tried it and it will only print variables once you have moved over the assignment line.
E.g. As soon as it starts up, you can't print $a, you have to go to next line, then print $a.

It seems the inbuilt debugger appears to run a line behind, since it shows you the next line before it executes it?
 
I just tried it and it will only print variables once you have moved over the assignment line.
E.g. As soon as it starts up, you can't print $a, you have to go to next line, then print $a.

It seems the inbuilt debugger appears to run a line behind, since it shows you the next line before it executes it?

Pretty much, well basically it was my fault using n (next) rather than getting it to run between break points using c (continue) :/ :p
 
Back
Top Bottom