Compiled regex error?

2006-02-20 Thread Maurice Height
I have just solved a bug in my code involving a compiled regex.
I am wondering if I have got it wrong or if this is a Perl error.
To explain...

I had a class ABC in which I passed a value to the constructor
(eg: $arg{delim_str} ) and stored this for later use throughout the class:

   $self-{DELIM_RE} = qr/\Q$arg{delim_str}\E/os;

Now when I create 2 class objects, each with a different value of
$arg{delim_str}, the first instance works correctly, but the second
seems to be using the same value that was created in the first instance.

For example:

   my $abc1 = ABC-new( delim_str = q{|} ); 
   # do some stuff with $abc1
   

   my $abc2 = ABC-new( delim_str = q{,} );
   # do some stuff with $abc2
   *** does not work because the value of $self-{DELIM_RE}
   *** used in $abc2 is the same as that in $abc1

However if I remove the 'o' option from the regex, everything is OK.

   $self-{DELIM_RE} = qr/\Q$arg{delim_str}\E/s;

I had assumed that even though a regex is compiled once only with the 'o'
option, that instances of class data would be INDEPENDENT of each other.

Any comments welcome...

Maurice 


___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Controlling fonts in Tk

2004-11-11 Thread Maurice Height
Hi all,

My setup is Activeperl v5.8.4 build 810, Tk v804.026 running on Win2K.
I wrote a little test program that uses Tk to display a window with
a menubar along the top.  I have tried to adjust fonts globally for the Menu
but the code at lines 15 and 19 has had no effect, see:
# HAS NO EFFECT!
The code on line 24 works OK but I want to change the font for the entire
menu including the label 'File'.
Can anybody point me in the right direction?

# Menu.pl
use strict;
use warnings;
use Tk;

my $mw  = MainWindow-new(-title  = 'Testing Tk::Menu',
  -width  = 500,
  -height = 300,
  -background = 'yellow',
  -name   = 'Demo',
 );
$mw-minsize(500,300);

my $menubar = $mw-Menu(-type = 'menubar',
-font = Verdana 14 bold,  # HAS NO EFFECT!
   );

$mw-configure(-menu = $menubar);
$menubar-configure(-font = Verdana 14 bold); # HAS NO EFFECT!

my $m1 = $menubar-cascade
 (  -label = 'File',
-tearoff   = 0,
-menuitems = [[Button = 'New',  -font= Verdana 16 bold,
  -command =
\create_new_file ],
   [Button = 'Open', -command =
_file   ],
   [Button = 'Exit', -command = sub
   ],
  ]
 );

MainLoop;

sub create_new_file { print create_new_file...\n; }

sub open_file   { print open_file...\n; }

__END__



Thanks in advance
Maurice


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs