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

Re: 'Dynamic scoping' of capture variables ($1, $2, etc.) (localization of captures in recursions is buggy!)

by LanX (Chancellor)
on Dec 16, 2012 at 21:03 UTC ( #1009094=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      DB<112> sub tst2 { 'a' =~ /(\w)/; $1. tst(). $1 }
     => 0
    ...
      DB<114> 'c' =~ /(\w)/; print $1. tst2(). $1
     => 1
    cabac
    
  2. or download this
      DB<123> sub delchar { $x =~ s/(\w)// ? $1 . delchar() . $1 : "x"  } 
     => 0
     
    ...
     
      DB<125> delchar()
     => "cccxccc"
    
  3. or download this
      DB<138> sub del1 { $x =~ s/(\w)// ? $1 . del2() . $1 : "x"  } 
     => 0
    ...
     
      DB<142> $x='abc'; del1()
     => "abcxcba"
    
  4. or download this
      DB<111> sub del2 { $x =~ s/(\w)// ? $1 . del1() . $1 : "-"  } 
     => 0
    ...
     
      DB<113> $x='abcd'; del1()
     => "cdcd-dcdc"
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009094]
help
Chatterbox?
Corion idly wonders if there is a way to produce ordered .yml files. I want to accept YAML for a configuration file format, but I also want to generate (for debugging/start) a sample configuration file from the current configuration.
[Corion]: Ideally, that configuration file would have some order of the keys, but I'm not sure whether/how YAML supports ordered output.
[Corion]: Basically I have this metadata and generating a purposeful example is much better if the output is ordered in the same way the documentation is ordered

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-01-16 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (149 votes). Check out past polls.