Part of the messy structure is of course due to the fact that it is a cleanup.
The initialisation of the hash was done in the BEGIN section, I wanted to preserve the original structure, but apart from that, there is no real need and it can indeed be replaced by a subroutine call.
Difficult to say where such a cleaning effort should stop and hints on that would be most welcome too.
This is part of my BEGIN section, I left out part of the here document, as it is not instructive, but it is of course the source of the big hash:
# # Intiliase global data and hint settings # BEGIN { %database_platforms = ( "ora" => "Oracle", "sql" => "Sybase", "mss" => "Mssql" ); my %hints_setting = ( "MODULE" => \&set_object_module_hint, "TYPE" => \&set_object_type_hint, "TEMPLATE" => \&set_object_template_hint ); my $hints = <<HINTS_DATA; TYPE:unknown:f_ali_alb_init_profile.mss:procedure TYPE:unknown:f_ali_alb_init_profile.ora:procedure MODULE:unknown:v_state_dr.ora:misc HINTS_DATA my @hints = split /\n/, $hints; foreach (@hints) { chomp; my @line = split /:/; my $proc = $hints_setting{ shift @line }; &{$proc}( @line ) if ($proc); } $history_delimitertext = "--DO NOT CHANGE BELOW THIS LINE--LASTLOG +="; }
The (already exisitng) module set_object_module_hint goes as follows:
sub set_object_module_hint { my ($project) = $_[0]; my ($objectname) = $_[1]; my ($modulename) = lc ($_[2]); $modulename =~s/\s//g; my ($result); $result = 0; if ($modulename eq "misc") { if (exists $object_module_hints {$objectname}) { log_message "Overriding module hint '$modulename' for data +base object name '$objectname'"; } $object_module_hints {$objectname} = $modulename; $result = 1; } else { log_error "Invalid module hint '$modulename' for database object + name '$objectname'"; } return $result; }
The global variable is used in some places, but not too many, so I am inclined to follow your suggestion.

Tabari

In reply to Re^4: __DATA__ used in BEGIN by Tabari
in thread __DATA__ used in BEGIN by Tabari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.