On 9/7/07, Beginner <[EMAIL PROTECTED]> wrote:
> On 7 Sep 2007 at 9:47, Chas Owens wrote:
>
> > On 9/7/07, Chas Owens <[EMAIL PROTECTED]> wrote:
> > snip
> > > #FIXME: this creates invalid dates like 2007-02-30
> > > sub rand_date {
> > >         sprintf "%04d-%02d-%02d",
> > >                 2000 + int rand 7,
> > >                 1 + int rand 12,
> > >                 1 + int rand 31;
> > > }
> > snip
> >
> > Actually that sub can't return "2007-02-30", kudos to anyone else who
> > can spot why.
>
> No return statement?

Nope, Perl returns the value of the last executed statement.  This is
useful for when I am feeling lazy (notice the bad use of IO::All) and
don't want to type return.  The code works (it returns dates strings),
but it can't return the string I mentioned in the comment (due to my
being an idiot).

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to