Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

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

by stefp (Vicar)
on Feb 03, 2006 at 09:49 UTC ( [id://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)

Replies are listed 'Best First'.
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 (Sage) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527577]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-19 15:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found