Anti-nuisance lawsuit warning: The purpose of these notes is to remind me, Zoegond, of stuff or to help me work stuff out. They may contain mistakes.

Quick

  • ($a, $b....) = unpack("A2A7...", $packed)
  • push( array, list )

Tuesday, February 14, 2012

Perl missing comma gotcha

Suppose you set up a window thusly

$self->{ww} = Win32::GUI::Window->new(
-name => 'Main',
-text => 'Vstatscheck',
-width => 100,
-height => 100 ,
-onTimer => sub { $self->cycle(@_); } # oops missed out the comma
-onTerminate => sub { $self->terminate(); }
);

the -onTerminate bit will be interpreted as a subtraction and neither your Timer or Terminate handlers will be properly set.

If, unlike me, you heed the advice to use the -w switch, you'll get a warning of this. Otherwise you won't. Foolishly perhaps I hardly ever use -w because I can't tell the useful warnings from the useless ones.

Followers

Blog Archive