in reply to Re: Useless use of string in void context
in thread Useless use of string in void context
So I want to save the truth value of the combined tests, with the expectation of using it more than once in my module. The first is a configuration value: 0 for no simulating, 1 for development simming and 2 for the expected situation in production, followed by one of two additional requirements for the need to set the "suppress" flag (which will later in the code suppress errors from an unenhanced component being delivered by someone else). I don't want to do it differently, e.g. an if or a ternary or something, because it would look more naff - Perl should not be warning me into producing worse code. So after due consideration, I opted to isolate the assignment instead of avoiding it.my $suppress = ($self->{simpos} == 1) and (($typ eq 'BHC') || ($typ eq 'ISC' +));
Update: my bad, spoke too soon: I needed an extra bracket around the whole assignment and the warning goes away on its own. The lack of an outer bracket indeed renders the last two tests useless, so Perl was right after all.my $suppress; { no warnings; $suppress = ($self->{simpos} == 1) and (($typ eq 'BHC') || ($typ eq 'ISC' +)); }
my $suppress = (($self->{simpos} == 1) and (($typ eq 'BHC') || ($typ eq 'ISC +' +)));
One world, one people
|
|---|