running it produces no big surprises:#!/usr/bin/perl our @fields; use mem(@fields=qw(one two three)); use Data::Vars \@fields, {one=>1, two=>2, three=>3}; use P; my $self=main->new(); P "one=%s, two=%s, three=%s", $self->one, $self->two, $self->three;
Where my surprise has come is trying to run in under 5.14 on cygwin. I get an immediate error:> /tmp/t.pl one=1, two=2, three=3
This has me stumped, since the line it is pointing to just has the "}" on the line (it closes a routine I call the 'main workhorse' of the class). Additionally, in that routine, there ARE no uses of '&&'. While the Vars.pm module has other code in it, this work horse routine is relatively short at 44 lines:> /tmp/t.pl Can't modify logical and (&&) in lvalue subroutine return at /Users/la +w.Bliss/bin/lib/Data/Vars.pm line 108, near "}" BEGIN not safe after errors--compilation aborted at /Users/law.Bliss/b +in/lib/Data/Vars.pm line 111. Compilation failed in require at /tmp/t.pl line 4. BEGIN failed--compilation aborted at /tmp/t.pl line 4.
The line with the 'endsub' is line #108 -- the line with the message that says:sub _Var ($$$;$) :lvalue { # Wrkhorse code for manu +fctrd Vars my ($p, $vn, $wa) = @{(shift)}; # vn=varname my $c = ref $p || $p; my $rfv = ref $p->{$vn}; # rfv=ref(type) of var my $addrof; if ($wa && $wa eq 'α') { $wa=undef, $addrof=1 } my $arg = $_[0]; if (@_ && !$addrof) { # arg for "setter" my $rfa = ref $arg; # ref of the arg unless ( defined($p->{$vn}) && defined $arg ){ # if both not de +fined $p->{$vn} = $arg } elsif ($rfv eq ARRAY) { ## if type(var)==ARRAY, +1 param my ($index, $ap) = (shift, $p->{$vn}); if ($p->{':pusharray'} or ( !looks_like_number($index) || not( (defined $wa) || @_) )) { push @{$p->{$vn}}, ($index); ## convert to "push" return $index } ## return pushed val +ue else { $p->{$vn}[$index] = $_[0] if @_; return $p->{$vn}[$index] if defined $wa } } elsif ($rfv eq HASH) { my $subvar = shift; ## 1 var w/hash is is +a key $p->{$vn}{$subvar} = $_[0] if @_; ## another? =>assign +value return $p->{$vn}{$subvar} if defined $wa } else { if ((length $rfv) && $rfv ne $rfa ) { ## incompat assignment warn P "Warning: var type redefined from \"%s\" to \"%s\"", $rfv, $rfa } $p->{$vn} = $_[0]; ## assignment is default return $p->{$vn} if defined $wa } } # how to return results? + (below) if ($rfv eq ARRAY ) { if (defined($wa)) { # arrays special $wa? @{$p->{$vn}} : $addrof ? \$p->{$vn} : $p->{$vn} } } elsif ($rfv eq HASH ) { $p->{$vn} } elsif ($addrof) { return $p->{$vn} } else { return $p->{$vn} } } ## endsub (#108) # "address(ref)-of" function ( sub _addr_of_($) { (#111 -- basically next line of code)
in it.can't modify logical and (&&) in lvalue subroutine return.
Not very helpful. Trying to run it under the debugger, I get a bit more information:
I.e. The problem might be closer to 144? What is there?...> perl -d bin/dedup Loading DB routines from perl5db.pl version 1.33 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. Can't modify logical and (&&) in lvalue subroutine return at /Users/la +w.Bliss/bin/lib/Data/Vars.pm line 108, near "}" BEGIN not safe after errors--compilation aborted at /Users/law.Bliss/b +in/lib/Data/Vars.pm line 144. at /Users/law.Bliss/bin/lib/Data/Vars.pm line 144. require Data/Vars.pm called at bin/dedup line 21 main::BEGIN() called at /Users/law.Bliss/bin/lib/Data/Vars.pm +line 144 eval {...} called at /Users/law.Bliss/bin/lib/Data/Vars.pm lin +e 144 Compilation failed in require at bin/dedup line 21. at bin/dedup line 21. main::BEGIN() called at bin/dedup line 21 eval {...} called at bin/dedup line 21 BEGIN failed--compilation aborted at bin/dedup line 21. at bin/dedup line 21. Debugged program terminated. Use q to quit or R to restart, use o inhibit_exit to avoid stopping after program termination, h q, h R or h o to get additional info. DB<1>
...Another closing brace and no '&&' in sight. That is called from line 21 in dedup:BEGIN { #140 if (require "Dbg.pm") { # import if there, else not; no error if + not using TPe Dbg->import; } #143 } #144
...This would seem to be a normal line to define & init vars in that module. Still no sign of logical 'AND'.use Data::Vars \@fields, {mmap=>1, aio_respQ=>{}, examine_paths=>[], S +YS_IO=>1, use_child_ra=>1};
....Hmmm... I'm stumped. If anyone knows the secret code behind the above encrypted error message... and could explain what I should be looking for to fix, (or what I should fix), would appreciate it. I' be happy to post the rest of Data::Vars (~400 lines total), if people think that would be useful.
Anyone seen this type of error before...? The closest I can think of is when I have tried something like:
But don't see anything resembling that in the above or the rest of the code.$a==NULL && $a=xxx; (needs parens or 'and' instead of '&&').
Ideas?
In reply to weird error message in middle-aged-perl(5.14) by perl-diddler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |