Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: when $$s =~ m/\G.../gc is too verbose (for)

by stefp (Vicar)
on Feb 03, 2006 at 09:49 UTC ( #527577=note: print w/ replies, xml ) Need Help??


in reply to Re: when $$s =~ m/\G.../gc is too verbose (for)
in thread when $$s =~ m/\G.../gc is too verbose

This is the trick used by Calc.yp in the Parse::Yapp distribution. It indeed creates an alias but conveys the wrong message because the the block is not really used as a loop.

-- stefp


Comment on Re^2: when $$s =~ m/\G.../gc is too verbose (for)
Re^3: when $$s =~ m/\G.../gc is too verbose (for)
by bart (Canon) on Feb 03, 2006 at 11:15 UTC
    That's why I wished Perl allowed another keyword as yet another synonym for for/foreach — I'd propose "with", for example:
    with($$s) { ... }
    But in the meantime, I've trained myself to actually read/see
    for(SCALAR) { ... }
    as
    with(SCALAR) { ... }

    Chalk it up as another Perl idiom.

      It's called "given" in Perl 6 (or in Perl6::Switch, if you want to play with 6ish topicalizers in Perl 5).

      Perl 6 also has syntactic relief for the m/\G.../gc monstrosity as well. That turns into m:p/.../, where the :p tells it to start matching at the current position. (But generally you don't even need that since subrules in a grammar always anchor to the current position anyway.)

Re^3: when $$s =~ m/\G.../gc is too verbose (for)
by tye (Cardinal) on Feb 03, 2006 at 19:45 UTC

    Much like in English, you can use Perl's for() for iterating over a list, iterating via initialization + check + step, or associating a single topic with a block of syntax. So I, without apology, use for() for topicalizing. For you, I won't stop doing this. (: Excuse me for not demonstrating the use of English "for" analogous to init + check + step.

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-12-25 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls