I m trying to know hot to properly return from a goto ?
That is,is there an instruction/statement/command that would return to the exact place (after the goto) from inside a goto ?
That instruction/statement/command would be in line 4 of both goto-0.pl goto-1.pl replacing goto CONT; AND retn; respectivly
I have read a few files about the goto statement
I have Google search for a perl statement to get out of a goto label and resume where it left off
perl exit goto
perl return goto
perl resume goto
perl quit goto
but did't find anything usefull

I finally came accross retn and made the goto-1.pl test program printed bellow but there is 1 major flaw with it;it prints 012345678910111213141516171819 WITHOUT printing ---- and a NEWLINE after each number that is,print "----\n"; line 8 is NEVER executed. So I presume retn just jumps back BEFORE goto LOOP; rather than AFTER
So, as a last resort I have done a version (goto-0.pl) whereas I use another label CONT to goto where I jump right after goto from within LOOP label and works but gets warning messages (just bellow)
I have tested the goto-0.pl test program and got the warning message
Use of "goto" to jump into a construct is deprecated at goto-0.pl line 4.
for use of a goto (line 4) in the middle of a while (line 7) but the program work fine
but found nothing about how to return (no return (return can only be used within a sub), no exit, no end WITHIN a goto) from where I left,that is just before the CONT label so I used it.
is there a way a way to return from where we left as in the return statement when using a sub ?
Failling the above how I can hush the above warning message using something else than
perl goto-0.pl 2> /dev/null
that works from the outside. I better like to hush from within using command-line-argument/option/switch and searched man perl the only command-line-argument/option/switch I have found is -U but still outputs to STDERR

I have Google searched
perl CLA command-line-argument option switch hush inhibit warning
but found nothing

goto-0.pl test program
$a=0; LOOP: print $a++; goto CONT; while ($a < 20) { goto LOOP; CONT: print "\n"; }

goto-1.pl test program
$a=0; LOOP: print $a++; retn; while ($a < 20) { goto LOOP; print "----\n"; }

Althought both programs work fine I m a bit concerned about the above warning messages for jumping in the middle of a while

In reply to how to return from a goto ? by perl_boy

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.