jZed has asked for the wisdom of the Perl Monks concerning the following question:

The following works fine (on debian with perl 5.8.4) without the "use encoding" line but produces a segfault with it. Any ideas why?
# cat > MyEncode.pm package MyEncode; my $re = '(?:\.|\.\.¦\/)'; sub test { return 1 if $_[0] =~ /^$re/;} 1; # cat > MyEncode.pl #!/usr/bin/perl -w use strict; use encoding 'latin2'; use MyEncode; print "ok!" if MyEncode::test('./foo'); # ./MyEncode.pl Compilation segmentation fault at ...
UPDATE thanks to erix who pointed out that I should be using |, not ¦ in the regex. Problem goes away once that's fixed.

Replies are listed 'Best First'.
Re: Segfault with "use encoding"
by borisz (Canon) on Jan 23, 2005 at 22:44 UTC
    Works fine for me.
    Update: I tested with | not the char in the original re
    lisa:~ borisz$ perl -V Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Platform: osname=darwin, osvers=7.3.0, archname=darwin-thread-multi-2level uname='darwin sherm-pendleys-computer.local 7.3.0 darwin kernel ve +rsion 7.3.0: fri mar 5 14:22:55 pst 2004; root:xnuxnu-517.3.15.obj~4r +elease_ppc power macintosh powerpc '
    Boris
Re: Segfault with "use encoding"
by talexb (Chancellor) on Jan 23, 2005 at 22:52 UTC
    "my" variable $re masks earlier declaration in same scope at MyEncode. +pm line 2. Subroutine test redefined at MyEncode.pm line 3.

    Hmm .. I got a syntax error. Mandrake 10, Perl 5.8.3.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds