Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • POE is neat, but you need to be careful you don't dispatch too many of the same events too often. I guess this is what you'd call a POE design pattern to watch out for...

    So instead of:

    • sub process_files {
          my ($kernel, $files) = @_[KERNEL, ARG0];
          $kernel->yield('process_file', $_) for @$files;

    I now have:

    • sub process_files {
          my ($kernel, $files) = @_[KERNEL, ARG0];
          if (@$files) {
              my $file = shift @$files;
    • I'm curious. In the original you had:

          $kernel->yield('process_file', $_) for @$files;

      and in the revised version:

          $kernel->yield('process_files', $files);

      Does yield take a list ref (and the for wrapper was not needed in the original) or is this a bug in the revised version?
      • First of all, you're looking at 'process_file' vs 'process_files'. So what the second version does is shift one file off the list, and call process_file on it, and then call process_files on the remaining files.

        $files is an array ref, and $file is a scalar.

        In POE, yield only cares about the first argument, which says which state to call. The rest of the arguments are passed in @_ and accessed via the ARGN aliases.