Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Answer: Is there any way I can use object.method() instead of object->method()?

( #189343=categorized answer: print w/ replies, xml ) Need Help??

Q&A > object-oriented programming > Is there any way I can use object.method() instead of object->method()? contributed by jeffa

I searched CPAN for Perl6 and did not find any modules that offer that ability yet. You could do something like:
use strict; my $code = do {local $/;<DATA>}; $code =~ s/(\w)\.(\w)/$1->$2/g; $code =~ s/(?<!\w)_(?!\w)/./g; eval $code; die $@ if $@; __DATA__ my $foo = Foo.new(); $foo.foo('foo'); $foo.bar('bar'); $foo.baz('baz'); print $foo.foo _ "\n" _ $foo.bar _ "\n" _ $foo.baz _ "\n"; package Foo; use Class::MethodMaker new => 'new', get_set => [ qw /foo bar baz / ];
but not only is that twisted (and silly), there is more than likely some usage of . and _ that i missed with the regexes. Best to just stick with the arrow notation - it is only one more character to type, after all ... that or start using Python ... /duck

UPDATE: belg4mit++ for suggesting Filter::Simple - i missed that one ...

Comment on Answer: Is there any way I can use object.method() instead of object->method()?
Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2015-07-01 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (25 votes), past polls