#!/usr/bin/perl -w
use strict;
my $x = 3;
for(1..3){
my $y = $x;
$y++;
$x -= $y;
}
The above little programme, if I put an acton on line 6 ($y++) the action occurs at line 6, line 7 then at line 5 where it is invalid ($y not defined)
To illustrate here is my session in the debugger...
DB<3> a 6 print ("\$y $y\n")
DB<4> n
DB<4>
DB<4>
$y 3
DB<4>
$y 4
DB<4>
Use of uninitialized value $y in concatenation (.) or string at (eval
+9)[/usr/share/perl/5.18/perl5db.pl:732] line 1.
at (eval 9)[/usr/share/perl/5.18/perl5db.pl:732] line 1.
eval 'no strict; ($@, $!, $^E, $,, $/, $\\, $^W) = @DB::saved;pack
+age main; print ("\\$y $y\\n");
' called at /usr/share/perl/5.18/perl5db.pl line 732
DB::eval called at /usr/share/perl/5.18/perl5db.pl line 2661
DB::DB called at test.pl line 5
$y
DB<4>
Clearly I misunderstand the manual. How do I do an action so it happens on only one line?