Beefy Boxes and Bandwidth Generously Provided by pair Networks httptech
Perl-Sensitive Sunglasses
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-04-17 11:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (446 votes), past polls