Good morning cellmates, I've been tasked with converting an old UNIX scripted system into Perl. This in itself is not a great - though long and tedious - task, however it occurs to me that this system could be much improved upon espescially when jobs failed! I won't tell you what has to be done when a job fails as well......the shame the shame! Anyway I was going to implement a method that I used in the old mainframe - memories! - days but there doesn't appear to be a "go to" facility in Perl can this be true? If so is there any other method available that will allow me to jump code given certain conditions?
Example :- A script has 50 programs to run and fails at step 35. At the moment the programmer has to make a copy of the original script, removes the first 34 steps and then runs this "new" script once before scrapping it. I want to automate failures using the original script. To this end each program within this script becomes a step - prog 10 is step 10. After completeing a step the step number is written to a file (if the run finishes completely the step file is deleted!) On running this script the first thing done - after standard parameter validation - is to see if the stepfile exists. If it does this is a re-run and whatever step number this file contains is where the script re-starts. This is the reason for a goto. I don't think that my program logic is flawed here as the goto is only to be used as part of this automatic re-start code and as such will only be used once.

Sorry but some of the reponses are idealogical clap trap! "I've never used a goto" indicates a lack of experience not knowledge. Unlike some people I know why using goto is frowned upon - and not just in Perl Cobol SCL etc - but that doesn't alter the fact that there are times and places where it's use is required! This is one such case! I want to AUTOMATE job failures - this means that the code doesn't get changed after a failure,it's simply well written enough to be re-run once the problem has been circumvented! Now maybe some people like to tinker with the same code everytime a job failure occurs but I prefer to get on with new work and if the inclusion of a (shock horror ) goto is going to allow that progress then that's what should be done. So please whether you've been programming for a couple of years or like some of us 20 odd years please respond to the question not demonstrate petty prejudice! One last thought for the prejudiced amongst us.... if it turns out that the only way to do something - and don't tell me this will NEVER happen because every single platform that I've programmed for has had such an occasion - is to use a goto what will you do? Say to the boss it can't be done because it offends me? I don't think so!

In reply to Go to? by Ronnie

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.