Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)

by sandfly (Beadle)
on Oct 17, 2003 at 20:48 UTC ( #300153=note: print w/ replies, xml ) Need Help??


in reply to Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)
in thread TIMTOWTDI doesn't mean invent an outlandish approach (usually)

I feel compelled to reveal a guilty secret... I have an irrational dislike of $#array. It seems superfluous.

Although I use "$array[$#array]" in preference to "$array[@array-1]", I don't enjoy it, and generally prefer to avoid the whole construction. And I always use "$i <= @array" instead of "$i < $#array".


Comment on Re: Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)
Re: Re: Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)
by Juerd (Abbot) on Oct 17, 2003 at 22:06 UTC

    I hope I will never have to maintain your code. (Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.)

    Anyway... Why the hell would you use $array[$#array]? $array[-1] is so much easier.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Re: Re: Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)
by runrig (Abbot) on Oct 18, 2003 at 01:17 UTC
    Although I use "$array[$#array]" in ...

    Have you anything against $array[-1] ??

    Update: Juerd already said it. Must be time to go home...

Re: Re: Re: TIMTOWTDI doesn't mean invent an outlandish approach (usually)
by antirice (Priest) on Oct 18, 2003 at 12:47 UTC
    ...And I always use "$i <= @array" instead of "$i < $#array"...

    I hope not since they don't mean the same thing unless $[ = 2. However, please realize that $#array is actually:

    $#array = $[ - 1 + @array;

    In other words, if anyone ever sets $[ to anything other than the default 0, not only do they then deserve to be beaten with a rubber mallet but they also break your code. Of course, I'm one of those weirdos who does stuff like:

    my @acceptable = grep { check $array[$_] } ($[..$#array);

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://300153]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (11)
As of 2014-09-16 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (34 votes), past polls