[comp.lang.perl] return from main

tchrist@convex.com (Tom Christiansen) (10/07/90)

Trying to return from main causes an error message.

perl -e 'return 1'
Bad label: _SUB_ at /tmp/perl-e025554 line 1.

I would like to see a return from main to be the 
same as exit, just as it is in C.

In any event, it shouldn't complain about a Bad Label.

--tom

ps: I'm at Patchlevel 18.
--
 "UNIX was never designed to keep people from doing stupid things, because 
  that policy would also keep them from doing clever things." [Doug Gwyn]

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (10/08/90)

In article <106927@convex.convex.com> tchrist@convex.Com (Tom Christiansen) writes:
: Trying to return from main causes an error message.
: 
: perl -e 'return 1'
: Bad label: _SUB_ at /tmp/perl-e025554 line 1.
: 
: I would like to see a return from main to be the 
: same as exit, just as it is in C.

Why?  Using "return" when you mean "exit" does not enhance readability.

: In any event, it shouldn't complain about a Bad Label.
: 
: --tom
: 
: ps: I'm at Patchlevel 18.

Obviously.  This was "fixed" in patch 19.  It now says

    Can't return outside a subroutine at /tmp/perl-e025554 line 1.

Larry