Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-18 Thread Jan Henning Thorsen
Yes. That is what I tried to write :-) On Thursday, December 18, 2014 12:41:39 AM UTC+1, Charlie Brady wrote: On Wed, 17 Dec 2014, Jan Henning Thorsen wrote: Pavel, you can do this: my $b = __PACKAGE__-can($a); $b-(stuff) if $code; I guess you mean: $b-(stuff) if $b; --

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-17 Thread Jan Henning Thorsen
Pavel, you can do this: my $b = __PACKAGE__-can($a); $b-(stuff) if $code; You can replace __PACKAGE__ with whatever package name you want. The special symbol __PACKAGE__ contains the current package, can() returns a ref to a function/method if $a has the correct method name which can be found

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-17 Thread Charlie Brady
On Wed, 17 Dec 2014, Jan Henning Thorsen wrote: Pavel, you can do this: my $b = __PACKAGE__-can($a); $b-(stuff) if $code; I guess you mean: $b-(stuff) if $b;

[Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Pavel Serikov
Hi everyone, I need to pass as input parameter of one function name of other function which must be executed in some cases. But cause of Mojolicious uses 'strict refs' I have no idea how to do it :( Can you please advice me something? For better understanding problem let me give an example:

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Денис Ильиных
пятница, 12 декабря 2014 г. пользователь Pavel Serikov написал: Hi everyone, I need to pass as input parameter of one function name of other function which must be executed in some cases. But cause of Mojolicious uses 'strict refs' I have no idea how to do it :( Can you please advice me

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Денис Ильиных
http://perldoc.perl.org/strict.html Maybe no strict 'refs' before you code and strict 'refs' after пятница, 12 декабря 2014 г. пользователь Денис Ильиных написал: пятница, 12 декабря 2014 г. пользователь Pavel Serikov написал: Hi everyone, I need to pass as input parameter of one function

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread sri
http://perldoc.perl.org/strict.html Maybe no strict 'refs' before you code and strict 'refs' after This is not good advice, i believe you should have good reasons for deactivating strict and warnings. -- sebastian -- You received this message because you are subscribed to the Google

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread sri
This is not good advice, i believe you should have good reasons for deactivating strict and warnings. And the real question that needs to be answered first is What are you actually trying to achieve?. If you want to work with subroutines as if they were references, just use subroutine

Re: [Mojolicious] How to use string as a subroutine ref in Mojo?

2014-12-12 Thread Pavel Serikov
Hi Sebastian, Thank you very much. Actually working solution is: my $a = test; sub test { print Hello World!\n; } my $b = \$a; $b-(); I hope that this code is considered as good style :) And the real question that needs to be answered first is What are you actually trying to achieve?.