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

I am having real issues with passing a string to lc. I have a series of objects that I set up, these objects have various settings in them. They follow the OO methodology pre moose. I then read an XML file which contains changes to some of these values and load these new values onto selected variables in my objects.

If I pass a variable string that I modify to lc I get a panic message. check out the code below,

# I tried to print it as a new string, this still fails my $newOpMode = sprintf "%s", $self->setTheOpMode; print length($newOpMode) . " $newOpMode ---" . length ($self->setT +heOpMode) . " " . $self->setTheOpMode."\n"; $return = 1 if ( (lc( $newOpMode )) eq "mitigate" ); # panics here

This gives me the following message, but if you check both strings they are the same

8 mitigate ---8 mitigate Use of uninitialized value in pattern match (m//) at /usr/share/perl/5 +.8/utf8_heavy.pl line 211. Use of uninitialized value in scalar assignment at /usr/share/perl/5.8 +/utf8_heavy.pl line 227. Use of uninitialized value in pattern match (m//) at /usr/share/perl/5 +.8/utf8_heavy.pl line 228. Use of uninitialized value in scalar assignment at /usr/share/perl/5.8 +/utf8_heavy.pl line 288. Use of uninitialized value in pattern match (m//) at /usr/share/perl/5 +.8/utf8_heavy.pl line 291. Use of uninitialized value in scalar assignment at /usr/share/perl/5.8 +/utf8_heavy.pl line 346. Use of uninitialized value in pattern match (m//) at /usr/share/perl/5 +.8/utf8_heavy.pl line 347. panic: swash_fetch at /home/root/pambuoy/smruPb-swup-v10.21/pgmon/../m +odules/rtdcStateLogic/rtdcSystemController.pm line 112.

The version the code fails on is v5.8.8 compiled for an ARM based overo, my development system is ubuntu (5.10.1), on which this code operates fine.

what is going on inside PERL and is there anything I can do without having to start compiling sections of code?

Replies are listed 'Best First'.
Re: panic: swash_fetch on passing a string to lc
by Anonymous Monk on Jul 26, 2012 at 06:39 UTC

      thanks, the pointer got me thinking, turns out I was loading from xml, where the encoding is utf-8, however I realised I could just convert these into utf8/latin1 perls internal data representation. Is that understanding correct?

      so when I use the following code things start working, if anyone has any other wisdom regarding exactly what is happening here that would be awesome.

      utf8::decode($newOpMode); print length($newOpMode) . " $newOpMode ---" . length ($self->setT +heOpMode) . " " . $self->setTheOpMode."\n"; $return = 1 if ( (lc( $newOpMode )) eq "mitigate" );

      http://perldoc.perl.org/utf8.html

      http://perldoc.perl.org/perlunifaq.html