The problem currently is like this, there is lot of different functions that wants different data and along the way they call other functions and so on. and i really need a fast way to tell when even one of them fails without changing too much code. as im trying find a solution that does not make things even more complicated than they already are, but still doing it most effective and reasonable way possible.

So after many hours of pondering, i can't really think a better way of doing this than those lovely goto labels everyone loves so much.

Here is a demonstration of the current solution.

#!/usr/bin/perl use strict; use warnings; my (%Numbers,$i); my @Values = qw/first second third/; $Numbers{$_} = ++$i for @Values; for my $cur (@Values) { my $value = &get_number ($cur); $value .= &get_ordinal ($cur); # more, more.. print "$cur is $value\n"; next; FAILED: print "WRONG: $cur, because: $@!\n"; next; } sub get_number { my $value = shift; if ($value eq "second") { &error("bad value"); } return $Numbers{$value}; } sub get_ordinal { return substr(shift, -2); } sub error { $@ = shift; goto FAILED; }

Just thought to ask if anyone ever dash against this kind of problem and found more elegant solution than the following. And yes i would rewrite it if it was up to me.

-Tauno, Thank you for your time.


In reply to Jumping trought lot of subroutines by Anonymous Monk

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.