in reply to using a subroutine

sub directs { ... &remove; }
When calling subroutines using the &, you should almost always use () also: &remove();. Not doing so gives the called routine access to the caller's @_; that is, a shift() in remove would take away one of direct's arguments. This can lead to hard-to-find bugs. &subname; without parens is only useful as an optimization in rare circumstances.

Alternatively, drop the & too, and either place the body of your subs before they are called, or use a forward declaration:  sub remove; sub declare;

Replies are listed 'Best First'.
Re^2: using a subroutine
by beable (Friar) on Aug 08, 2004 at 22:57 UTC
    Why not just place your subs whereever you like, call them from whereever you like without & and with (), and not use forward declarations either? What am I missing? Perl isn't C. This seems to work for me:
      I agree, but if you are in the habit of leaving off (), it may be easiest to predeclare.
Re^2: using a subroutine
by xjlittle (Beadle) on Aug 10, 2004 at 00:34 UTC
    Ditto, same as Brad ^