JStrom has asked for the wisdom of the Perl Monks concerning the following question:
But there is no reference to $_[2] in the code. I stripped out most of the module to hit the function: (Line 39 is the first line of parse_rvalue())"Use of uninitialized value $_[2] in pattern match (m//) at Plugin/Syn +tax.pm line 39."
And the test script:package Plugin::Syntax; use strict; use warnings; use Data::Dump; my $code; my $kw = qr/[A-Za-z_][A-Za-z0-9_-]*/; my %directives = map { $_ => 1 } (qw| !some !data !snipped| ); my %commands = map { $_ => 1 } (qw| some data snipped| ); sub parse_command { return unless $_[0] =~ /\G\s*($kw)\s*=\s*/cg; # not 'ident =' my $id = $1; my ($s,$e) = ($-[1],$+[1]); if( $id =~ /^(?:ok|e[0-9A-Fa-f]{2})$/ ) { $code->tagAdd( 'special', "$_[1] +${s}c", "$_[1] +${e}c" ); } if( $_[0] =~ /\G($kw)\s*\(/cg ) { # parse that command pos( $_[0] )--; # give back the paren if( exists $commands{lc $1} ) { # Check if command exi +sts $code->tagAdd( 'command', "$_[1] +$-[1]c", "$_[1] +$+[1]c" + ); } return lc $1; } # This must be an immediate value &parse_rvalue; return 'none'; } sub parse_rvalue { if( $_[0] =~ /\G[CS]?\d\d-\d\d(?:\s+var\s+[0-9A-Fa-f]{1,2})?/cg ) +{ $code->tagAdd('constant', "$_[1] +$-[0]c", "$_[1] +$+[0]c"); } elsif( $_[0] =~ /\G[CS]?[#][0-9A-Fa-f]{3}/cg ) { $code->tagAdd('constant', "$_[1] +$-[0]c", "$_[1] +$+[0]c"); } elsif( $_[0] =~ /\G\$?[0-9A-Fa-f][0-9A-Fa-f ]*(?!\w)/cg ) { $code->tagAdd('constant', "$_[1] +$-[0]c", "$_[1] +$+[0]c"); } elsif( $_[0] =~ /\G\$?$kw/cg ) { # indentifier, no highlight } elsif( $_[0] =~ /\G".*?"/cg ) { $code->tagAdd('constant', "$_[1] +$-[0]c +1c", "$_[1] +$+[0]c +-1c"); } elsif( $_[0] =~ /\G\@[^\s,)]*/cg ) { $code->tagAdd('constant', "$_[1] +$-[0]c +1c", "$_[1] +$+[0]c" +); } elsif( $_[2] =~ /^(?: hsm | cat | cat8 )$/x and $_[0] =~ /\G[<>;]/ +cg ) { } else { return; } return 1; } 1;
use strict; use warnings; use Plugin::Syntax; Plugin::Syntax::parse_command( "xx = ", "" );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Weird undefined variable warning
by brian_d_foy (Abbot) on Jan 18, 2008 at 23:37 UTC | |
|
Re: Weird undefined variable warning
by ysth (Canon) on Jan 18, 2008 at 23:27 UTC | |
|
Re: Weird undefined variable warning
by hipowls (Curate) on Jan 18, 2008 at 23:12 UTC | |
by dave_the_m (Monsignor) on Jan 18, 2008 at 23:36 UTC | |
by hipowls (Curate) on Jan 18, 2008 at 23:56 UTC |