Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Number of times I've used goto in Perl

by AnomalousMonk (Archbishop)
on Mar 25, 2015 at 22:03 UTC ( [id://1121349]=note: print w/replies, xml ) Need Help??


in reply to Re: Number of times I've used goto in Perl
in thread Number of times I've used goto in Perl

... &&= too techy ...

A bit too techy and, for these old eyes, just plain difficult to see! I think I'd incline toward something like (all untested)

sub fred { my ($t, $u, $v, $w, $x, $y) = @_; somelogger(5, "fred", "start of fred"); my $ok = 1; $ok = method1($t) if $ok; $ok = method2($u) if $ok; my $pid = open my $ph, "/somewhere/program $v |"; my $output = ''; $ok = method3(<$ph>, \$output) if $ok; close $ph; waitpid $ph,0; if ($ok) { somelogger(5, "fred", "fred completed successfully"); } else { somelogger(5, "fred", "error during fred"); } return $ok; }
or maybe even (assuming the methods can be made to return error strings or the empty string for no error)
sub fred { my ($t, $u, $v, $w, $x, $y) = @_; somelogger(5, "fred", "start of fred"); my $err; $err = method1($t) unless $err; $err = method2($u) unless $err; my $pid = open my $ph, "/somewhere/program $v |"; my $output = ''; $err = method3(<$ph>, \$output) unless $err; close $ph; waitpid $ph,0; if ($err) { somelogger(5, "fred", "error '$err' during fred"); } else { somelogger(5, "fred", "fred completed successfully"); } return $err; }


Give a man a fish:  <%-(-(-(-<

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121349]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-29 00:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found