--- "Pense, Joachim" <[EMAIL PROTECTED]> wrote: > >Von: Moran, Matthew
[mailto:[EMAIL PROTECTED]]
> >Gesendet am: Mittwoch, 20. November 2002 14:41
> >Joachim suggested:
>  
> >> sub commify {
> >>     my $max = shift;
> >>     my $sep = shift;
> >>     my $end = shift;
> >> 
> >>     ...
> >> }
> >> 
> >> better or even worse in your view?
> >
> >Clearer, but just as bad IMHO. I've always done it as
> 
> >sub subroutine(
> >     my ($list, &of, $variables) = @_;
> >#    rest of code here
> >}
> 
> >It's how it's always shown in the Cookbook & what have you.
> 
> Not *always*, I've seen my version explicitly suggested somewhere. The
> advantage in my eyes is that you consume the input parameters so they are
> gone when you read them. It is also easier to check in the end if there are
> any left so too many were supplied.

You mean you saw it in the holy book itself: "Programming Perl"
(aka The Camel).  Looking at page 374 we find:

sub TIEARRAY {
    my $class = shift;
    my $bound = shift;
    confess "usage: tie(\@array, 'BoundedArray', max_subscript)"
        if @_ || $bound =~ /\D/;
    return bless { BOUND => $bound, DATA => [] }, $class;
}

To bring this back inline with the original discussion, I was thinking the
problem could be solved with a tied array.  Starting at 372 it shouldn't
take long to implement the required code - left as an exercise for the
reader.

Jonathan Paton

=====
s''! v+v+v+v+  J r e P    h+h+h+h+ !s`\x21`~`g,s`^ . | ~.*``mg,$v=q.
 P ! v-v-v-v-  u l r e r  h-h-h-   !12.,@.=m`.`g;do{$.=$2.$1,$.=~s`h
 E !   v+v+v+  s     k e  h+h+     !`2`x,$.=~s`v`31`,print$.[$v+=$.]
 R !     v-v-  t H a c h  h-       !}while/([hv])([+-])/g;print"\xA"
 L !             A n o t           !';$..=$1while/([^!]*)$/mg;eval$.

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

Reply via email to