in reply to Why am I getting "syntax error at Funcy.pl line 18, near "$barney return" ?

You're missing a semicolon on the line my $sum = $fred * $barney.

Update: Also, note that since return will return from the sub, the if won't get executed. And I'm not sure why your if blocks only have one variable in them - if you're trying to return either one or the other value, don't use an if, use the Conditional Operator ?:, as in ( $fred > $barney ? $fred : $barney ).

Replies are listed 'Best First'.
Re^2: Why am I getting "syntax error at Funcy.pl line 18, near "$barney return" ?
by prospect (Acolyte) on Jul 24, 2017 at 08:42 UTC
    Omg I was stuck looking at line 18! Thank you, I thought I was going crazy :p (faith restored)
      Hi prospect,

      when you you have a syntax error indicating the last line of the program, it is very often the case that the actual error is somewhere earlier, sometimes much earlier, in the code.

      In these cases, the error is quite often a missing semi-colon, a missing closing quote mark for a string, a missing closing parenthesis or square bracket, and so on.

        Ok thank you for the explanation, just the kind of wisdom I was looking for going forward