Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

by jeffa (Bishop)
on Aug 11, 2002 at 22:26 UTC ( [id://189343]=note: print w/replies, xml ) Need Help??


in reply to Is there any way I can use object.method() instead of object->method()?

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 Re: 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://189343]
help
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found