<?xml version="1.0" encoding="windows-1252"?>
<node id="919370" title="Re^2: How to modify a warning message within a sub?" created="2011-08-08 23:53:45" updated="2011-08-08 23:53:45">
<type id="11">
note</type>
<author id="732669">
Marshall</author>
<data>
<field name="doctext">
THANKS!, I worked some more...this works..&lt;br&gt;
The good thing is that &lt;c&gt;$arrayRef-&gt;[1]&lt;/c&gt; works without having $arrayRef having more scope than within the sub{}.
&lt;p&gt;

&lt;c&gt;
#!/usr/bin/perl -w
use strict;
$|=1;              #turns off buffering for STDOUT

my @x = ( [1,'100'],
          [2,'106'],
          [3,'100A'],
          [4,'100B2'],
        );
        
foreach my $ref (@x)
{
   print "For $ref-&gt;[1] compareLT105 says: ", 
                        compareLT105($ref),"\n";
}
        
sub compareLT105
{
   my $arrayRef = shift;
   
   local $SIG{__WARN__} = 
      sub 
      {
          my $msg = shift;
          print STDERR $msg,"********";
          print STDERR "error array index: ",$arrayRef-&gt;[0]; 
          print STDERR " value is ",$arrayRef-&gt;[1], "\n";  
      };
  
   return 'true' if $arrayRef-&gt;[1] &lt; 105;
   
   return 'false';
}

__END__
For 100 compareLT105 says: true
For 106 compareLT105 says: false
Argument "100A" isn't numeric in numeric lt (&lt;) at C:\TEMP\warnexample.pl line 30.
********error array index: 3 value is 100A
For 100A compareLT105 says: true
Argument "100B2" isn't numeric in numeric lt (&lt;) at C:\TEMP\warnexample.pl line 30.
********error array index: 4 value is 100B2
For 100B2 compareLT105 says: true
&lt;/c&gt;
</field>
<field name="root_node">
919360</field>
<field name="parent_node">
919364</field>
</data>
</node>
