Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: the '..' operator and decreasing values

by phroggy (Monk)
on Mar 05, 2005 at 00:25 UTC ( [id://436824]=note: print w/replies, xml ) Need Help??


in reply to the '..' operator and decreasing values

That's roughly equivalent to:
for(my $i=10;$i<=0;$i++) { # do something }

You can't use .. to count backwards, but try this:

for my $i (reverse 0..10) { # do something }
for $a(-2,12){for $b(0..7){$c=0;$_?hex substr( ef7fa1866706caeff02289402844,2*$_+$a,2)&2**(7-$b):0 and $c+=2**(7-$_)for(0..7);print chr $c;}}

Replies are listed 'Best First'.
Re^2: the '..' operator and decreasing values
by jhourcle (Prior) on Mar 05, 2005 at 02:17 UTC

    You might prefer

    for ( my $i = 10; $i--; ) { # do something }

    I regularly walk array indexes backwards, as you can shave a few cycles off of the standard

    for ( my $i = 0; $i < $array_size; $i++ ) { # whatever }

    logic that people love using in those languages that don't have a 'foreach' command.

Log In?
Username:
Password:

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

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

    No recent polls found