#!/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?


In reply to Debugger actions: On which lines? by worik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.