Fellow monks I’m working on a class to automate IE. As part of that automation I need to support popups (NewWindows). I’ve encountered a problem that crashes PERL and have isolated it in the following code. Curiously, if the push that attempts to save the created IE's is commented out the code does NOT CRASH. I’m not sure why. Does anyone have any clues? Does the code work OK elsewhere? I’m completely mystified and uncertain where to look next.

YOU MUST DISABLE ALL POPUP BLOCKERS to test this code.

Slightly updated version of code (a bit easier to read).
#!/usr/bin/perl -w # this site has a large number of popup tests # http://www.kephyr.com/popupkillertest/test/index.html # http://www.kephyr.com/popupkillertest/test/test1.html ... 23 use strict; use Data::Dumper; use Win32::OLE qw( EVENTS ); use Time::HiRes qw(gettimeofday); my $self = {}; my $ie = Win32::OLE->new( 'InternetExplorer.Application' ) or die "error"; $ie->{visible} = 1; Win32::OLE->WithEvents( $ie, \&ie_events, 'DWebBrowserEvents2' ); $self->{ie} = $ie; $self->{popups} = []; $self->{ts} = $self->{tle} = gettimeofday; print "self after initialization\n" . Dumper( $self ); $|=1; # do not buffer sub navto($); # causes popup on 1st 2 loads #navto( 'http://www.cnn.com/' ); # no popup navto( 'http://www.google.com/' ); # single popup navto( 'http://www.kephyr.com/popupkillertest/test/test1.html' ); # two popups navto( 'http://www.gozer.org/mozilla/popup_tester/' ); # no popup navto( 'http://www.whitehouse.gov/' ); print "\n"; print "--------------------------------------------\n"; print "--------------------------------------------\n"; print "should see this if all is OK\n"; print "--------------------------------------------\n"; print "--------------------------------------------\n"; sub navto($){ my $url = shift; @{$self->{popups}} = (); $self->{ts} = $self->{tle} = gettimeofday; print "\n===================================================\n"; print "navigate to $url\n" . Dumper($self); $ie->navigate( $url ); while(gettimeofday - $self->{ts} < 60){ Win32::OLE->SpinMessageLoop; # check for events last if( gettimeofday - $self->{tle} > 10 ); } print "done $url\n" . Dumper( $self ); } sub ie_events(){ my( $ie, $event, @args ) = @_; my $tn = gettimeofday(); $self->{tle} = $tn; my $te = sprintf '%6.2f', $tn - $self->{ts}; print "$self $ie $te [$event]\n"; if( $event eq 'NewWindow2' ) { print "self before new window handling\n"; print Dumper($self); my $popupself = {}; my $ie = Win32::OLE->new( 'InternetExplorer.Application' ) or die( 'could not start IE on allowed NewWindow2' ); print "self after new IE application\n"; print Dumper($self); $popupself->{ie} = $ie; my $xx = $self->{popups}; push @{$xx}, $popupself; #works when commented out print "self after push\n"; print Dumper($self); #$args[0]->Put( $ie->{application}); $args[0]->Put( $ie ); $args[1]->Put( 0 ); } }

In reply to perl crash, Win32::OLE by puff

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.