Beefy Boxes and Bandwidth Generously Provided by pair Networks
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?
[stevieb]: do you have input coming in that you're parsing? if so, update the question. Also add an example of *exactly* what your desired output should look like given an example input
[stevieb]: valgrind doesn't catch a deep internal segfault issue :( sigh

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2017-04-29 03:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (531 votes). Check out past polls.