redtux has asked for the wisdom of the Perl Monks concerning the following question:
this works
This triggers strict 'refs'my $transref_chksql= <<~ 'SQLSTR'; SELECT CASE WHEN EXISTS (SELECT * FROM pg_class WHERE relkind = 'S' AND relname= 'encode_transref_seqm') THEN 'transref_seq_add' ELSE 'ignore' END SQLSTR my $transseqchk->{transchk}= ($dbh->selectrow_array($transref_chksql))[0]; my %actionsw; $actionsw{transref_seq_add}->{cmd}=sub{ (my $encode_transref_seqmsql= <<~ 'SQLSTR'); CREATE SEQUENCE IF NOT EXISTS transref_seqm Start 0 minvalue 0 OWNED BY encodes.fileid SQLSTR $dbh->do($encode_transref_seqmsql); }; if ($actionsw{$transseqchk->{transchk}}->{cmd}){ &{$actionsw{$transseqchk->{transchk}}->{cmd}}; }
The only difference is a further level of hash in the working examplemy %transseqchk; my $transref_chksql= <<~ 'SQLSTR'; SELECT CASE WHEN EXISTS (SELECT * FROM pg_class WHERE relkind = 'S' AND relname= 'encode_transref_seqm') THEN 'transref_seq_add' ELSE 'ignore' END SQLSTR my $transseqchk->{transchk}= ($dbh->selectrow_array($transref_chksql))[0]; $transseqchk->{transref_seq_add}->{cmd}=sub{ (my $encode_transref_seqmsql= <<~ 'SQLSTR'); CREATE SEQUENCE IF NOT EXISTS transref_seqm Start 0 minvalue 0 OWNED BY encodes.fileid SQLSTR $dbh->do($encode_transref_seqmsql); }; if ($transseqchk->{transchk}->{cmd}){ &{$transseqchk->{transchk}->{cmd}}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: When is strict 'refs triggered
by choroba (Cardinal) on May 22, 2020 at 14:05 UTC | |
by redtux (Sexton) on May 22, 2020 at 14:46 UTC | |
by choroba (Cardinal) on May 22, 2020 at 14:54 UTC | |
|
Re: When is strict 'refs triggered
by tobyink (Canon) on May 23, 2020 at 06:40 UTC | |
by redtux (Sexton) on Jun 10, 2020 at 14:09 UTC |