Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Speeding-up OO accessor methods

by mirod (Canon)
on Sep 19, 2000 at 01:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://33029]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found