Greetings to all! I'm trying to make work old code (proven to work on 5.8.6) with new perl (5.24.1), and in some point it goes to core dump. Here's my own localization class:
package Hello::Locale; use strict; use Encode qw(encode); require Locale::Maketext::Lexicon; use base qw( Locale::Maketext); our %Lexicon = ( _AUTO => 1 ); sub get_handle { my $class = shift; my( $lang, $enc ) = @_; my $self = $class->SUPER::get_handle($lang); $self->{encoding} = $enc; $self; } sub maketext { my $self = shift; my @params = @_; my $result = encode( $self->encoding(), $self->SUPER::maketext( @p +arams)); $result; } sub load { my $self = shift; my %params = @_; Locale::Maketext::Lexicon->import( { $self->language_tag() => [ %p +arams], _decode => 1}); 1; } package Hello::Locale::ru; use Hello::Locale; use base qw( Hello::Locale); our %Lexicon = (); our $LEXICON_LOADED = 1; 1;
Here's my a program to test my localization class:
#!/usr/local/bin/perl use strict; use Hello::Locale; use Data::Dumper; my $filename = shift; my $lh = Hello::Locale->get_handle("ru","KOI8-R"); $lh->load( Messages => $filename); no strict 'refs'; print Dumper( $lh ); print "Lexicon loaded\n" if ${ref($lh)."\::LEXICON_LOADED"} ; print Dumper( %{ref($lh)."\::Lexicon" } );
And here's a result:
% ./test.pl file.msg $VAR1 = bless( { 'encoding' => 'KOI8-R', 'blacklist' => { 'get_handle' => 1, 'new' => 1, 'encoding' => 1, 'language_tag' => 1, 'init' => 1, 'failure_handler_auto' => 1, '_ambient_langprefs' => 1, '_langtag_munging' => 1, '_die_pointing' => 1, 'maketext' => 1, '_compile' => 1, '_try_use' => 1, '__ANON__' => 1, 'whitelist' => 1, 'fallback_languages' => 1, '_lex_refs' => 1, 'blacklist' => 1, 'fail_with' => 1, '_add_supers' => 1, 'fallback_language_classes' => 1 } }, 'Hello::Locale::ru' ); Lexicon loaded Segmentation fault (core dumped)
Now, if i add before a call to $lh->maketext('ok') before print Dumper( %{ref($lh)."\::Lexicon" } ); line - it works and no core dumping. In short, with 5.8.6 i was able to access %subclass::Lexicon before calling $superclass->maketext('anything'), but with 5.24.1 i can't, as if %Lexicon is not exists before $superclass->maketext('anything') call. Is it normal?

In reply to Core dump while trying to access %Lexicon in Locale::Maketext subclass by alexander_lunev

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.