Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Speeding-up OO accessor methods

by mirod (Canon)
on Sep 19, 2000 at 01:03 UTC ( #33029=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/bin/perl -p
    
    # basic substitution
    ...
    s/((\$\w+)->field\b/$1\->\{field\}/g;
    # the set_field method has an argument, capture it
    s/s/(\$\w+)->set_field\(([^)]*)\)/$1\->\{field\}= $2/g
    
  2. or download this
    #!/bin/perl -p
    BEGIN { $FIELD="field1|field2|field3"; }
    s/(\$\w+(?:\[\d\])?)->($FIELD)\b(?!\()/$1\->\{$2\}/g;
    s/(\$\w+(?:\[\d\])?)->set_($FIELD)\(([^)]*)\)/$1\->\{$2\}= $3/g;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://33029]
Approved by root
help
Chatterbox?
[Corion]: Ouch. I just learned something about Chrome - the "version numbers" are not really feature numbers... Chrome 62 still gets new features even though Chrome 64 is out and Chrome 65 is the dev version
[erix]: why ouch? Something to be said for that ,surely?
LanX is a dev version
[marto]: That reminds me, I made some notes somewhere with regard W::M::C, I'll get round to a PR when I've time to flesh it out
[Corion]: erix: But that makes for fun bug hunting. "What version of Chrome are you running?" "v62". "I also run v62 and it works on my machine". :-(

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2017-12-12 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (335 votes). Check out past polls.

    Notices?