in reply to Using RETURN in a sub

Just a few snooty comments on style:

  1. Indent code within a subroutine's blocks to make it easier to recognize which parts are actually within the subroutine block. This should also be done for conditionals and any other type of block (for instance, closures).
  2. You should really use lexical variables in a subroutine by using my $variable = .... You are actually using package globals. Having multiple subroutines working on globals can result in unexpected behavior if you aren't aware of the problems they can cause.
  3. There is a wonderful quoting mechanism in perl called qw. It returns an array of all items between the delimiters split on space. For instance, you would set @days and @mons with:
    my @days = qw(Sun Mon Tues Wed Thurs Fri Sat); my @mons = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec);
  4. To quote from perldoc -f localtime:
    If EXPR is omitted, localtime() uses the current time (localtime(time)).
  5. You can use a list slice to set your variables thusly:
    my ($mday,$mon,$year,$wday) = (localtime)[3..6];

    This tends to result in clearer code since you don't have to search in a sea of undefs to find the variables.

  6. The expression 2000 + ($year - 100) can be reduced to 1900 + $year.
  7. You can simplify the expression $year = 1900 + $year to $year += 1900.
  8. You don't need an intermediate variable to return the stringification of your variables. Instead of:
    $date = "$days[$wday] $mons[$mon] $mday $year"; return $date;
    You could quite simply do:
    return "$days[$wday] $mons[$mon] $mday $year";

Put all of that together and you get:

sub makeDate { my @days = qw(Sun Mon Tues Wed Thurs Fri Sat); my @mons = qw(Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec); my ($mday,$mon,$year,$wday) = (localtime)[3..6]; $year += 1900; return "$days[$wday] $mons[$mon] $mday $year"; }

You may wish to read perldoc perlsub for information concerning the different ways of calling subroutines, perldoc perlstyle for recommended code formatting (just for a guideline until you can develop your own style), and perldoc perldata for more information about perl data types and how they can be accessed.