I am writing a POE::Component::DirWatch integrated with a SystemTray::Applet. The callback in SystemTray::Applet runs the POE script. I think in order for the actual icon to get created, the callback has to return. But since my callback will not return, no icon is created. How do I get around that one?

#!perl use warnings; use strict; use Data::Dumper; use Win32::Process; use File::Slurp; use SystemTray::Applet; use POE; # auto-includes POE::Kernel and POE::Session use POE::Component::DirWatch; my $user = "mwb"; my $app = SystemTray::Applet->new( text => 'Candela Dashboard', icon => 'C:\Documents and Settings\Mike\Desktop\Candela\dashboar +d.ico', callback => &poe_dir_watcher, immediate => 1, ); sub poe_dir_watcher { POE::Session->create( inline_states => { _start => sub { $_[KERNEL]->yield("next") }, next => sub { print "tick...\n"; $_[KERNEL]->delay(next => 1); }, }, ); my $watcher = POE::Component::DirWatch->new( alias => 'dirwatch', directory => 'V:', file_callback => sub{ load_crm($_[0]) }, interval => 1, ); POE::Kernel->run(); return; } sub load_crm { my ($file) = @_; my @data; if ($file =~ /$user/) { my @data = read_file("$file"); chomp @data; # replace ^ with | for (2..4) { ($data[$_] = $data[$_]) =~ s/\^/|/g; } my $result = run_firefox(\@data); unlink($file) if $result; } } sub run_firefox { my ($data) = @_; my $firefox = 'C:\Program Files\Mozilla Firefox\firefox.exe'; my $crm_url = "firefox http://ext-test.candelacorp.com/crm/nomo.pl" +. "?cust_num=" . $data->[0] . "&cont_num=" . $data->[1] . "&prod_num=" . $data->[2] . "&prod_qty=" . $data->[3] . "&prod_prc=" . $data->[4] ; print $crm_url, "\n"; Win32::Process::Create( my $ProcessObj, $firefox, $crm_url, 0, NORMAL_PRIORITY_CLASS, "." ) || die ErrorReport(); return 1; } sub ErrorReport{ print Win32::FormatMessage( Win32::GetLastError() ); }

In reply to Running a SystemTray::Applet with a callback in infinite loop by initself

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.