Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by sandfly (Beadle)
on Oct 17, 2003 at 20:48 UTC ( [id://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)

Replies are listed 'Best First'.
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

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...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-20 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found