Question: In Haskell (F#, Ocaml, and others), I can do this:

```
sign x |  x >  0        =   1
       |  x == 0        =   0
       |  x <  0        =  -1

```

Which calculates the sign of a given integer.

This can concisely express certain logic flows; I've encountered one of these flows in Perl.

Right now what I am doing is 

```
sub frobnicator
{
   my $frob = shift;
   return "foo" if $frob eq "Foomaticator";
   return "bar" if $frob eq "Barmaticator";
   croak("Unable to frob legit value: $frob received");
}

```

Which feels inexpressive and ugly.

This code has to run on Perl 5.8.8, but of course I am interested in more modern techniques as well.

Answer: 
Here's one other possible approach, which is still a bit wordy, but perhaps reflects the flow better. (In the book Perl Best Practices, the author suggests mostly avoiding the postfix form of `if` because you need to scan all the way to the right to understand what is going on.) You could add parentheses if that helps to highlight the condition.

```
sub sign
{
    my $x = shift;
    $x  > 0  and return  1;
    $x == 0  and return  0;
    $x  < 0  and return -1;
}

sub frobnicator
{
    my $frob = shift;

    $frob eq "Foomaticator" and return "foo";
    $frob eq "Barmaticator" and return "bar";

    croak("Unable to frob legit value: $frob received");
}

```
You could use the conditional operator:

```
sub frobnicator {
  my $frob = shift;
  return $frob eq 'Foomaticator' ? 'foo' :
         $frob eq 'Barmaticator' ? 'bar' :
         croak("Unable to frob legit value: $frob received");
}

```

It turns your original example into something like:

```
sub sign {
  my $x = shift;
  return $x < 0 ? -1 :
         $x > 0 ?  1 :
                   0 ;
}

```

Which, y'know, is a little ugly, but it gets the point across :-)