Dnia 2010-04-03, sob o godzinie 01:36 +0300, Gabor Szabo pisze:
On Sat, Apr 3, 2010 at 1:11 AM, sawyer x <xsawyerx@gmail.com> wrote:
On Sat, Apr 3, 2010 at 1:05 AM, Gabor Szabo <szabgab@gmail.com> wrote:
How can I launch the browser from the script and how can I do it *after* I called dance()
KiokuDB::Navigator uses Browser::Open to accomplish that. I can honestly say I found it nifty. :)
Hmm, I missed that one. Someone needs to improve search.cpan.org so it will find modules even if the user does not know how to search for the obvious name...
You can view the usage of it in the "run" method of KiokuDB::Navigator.
Nice.
I have now this code:
# TODO should be in the other way around Browser::Open::open_browser("http://localhost:3000/"); dance;
and it works but could be improved.
How could I launch dance in the background the easy way? (I guess --daemon is not the answer for me).
Maybe a dance_on_backstage(); ? and a wait_for_dance_to_finish() so I don't need to implement the ctrl-c handling myself.
dance_on_backstage(); Browser::Open::open_browser("http://localhost:3000/"); wait_for_dance_to_finish();
or maybe an even better integration in case the user launched the script with --port=4000
dance_with_the_fox()
That would load Browser::Open and call Browser::Open::open_browser.
I guess I am looking for suggestions how to implement these. Gabor _______________________________________________ Dancer-users mailing list Dancer-users@perldancer.org http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
Imo simplest solution would be to just run separate thread, something like: use threads; my $t = threads->create(\&browser); dance; sub browser () { sleep 1 ; Browser::Open::open_browser("http://localhost:3000/"); } -- Mariusz Gronczewski (XANi) <xani666@gmail.com> GnuPG: 0xEA8ACE64 http://devrandom.pl