site_generator uses subroutine prototypes #169

Closed
opened 2023-09-17 19:20:18 +00:00 by davmo · 1 comment
Collaborator

The subroutine get_template_html begins thus:

sub get_template_html (\%@)  {

The items in parentheses use the largely deprecated subroutine prototypes. The existence of this feature causes a warning to be produced.

The subroutine is called as:

    my $tt = get_template_html($config{DBI}, $config{app_paths});

Then the arguments are used to define a TT² template thus:

    return Template->new(
        {   INCLUDE_PATH => $_[1]{templates_path},
            OUTPUT_PATH  => $_[1]{output_path},


            CONSTANTS    => {
                database => $_[0]{database},
                driver   => $_[0]{driver},
                user     => $_[0]{user},
                password => $_[0]{password},
            }
        }

The %config variable is a hash containing various data structures. The $config{DBI} and $config{app_paths} elements are hashrefs, and are passed as such. If the subroutine prototypes had been omitted these would have been passed as hashrefs also.

The default argument array @_ is being used in expressions such as $_[0]{database} and is unaffected by the prototype.

Conclusion:

  • Remove the subroutine prototype used here
The subroutine `get_template_html` begins thus: ``` sub get_template_html (\%@) { ``` The items in parentheses use the largely deprecated subroutine prototypes. The existence of this feature causes a warning to be produced. The subroutine is called as: ``` my $tt = get_template_html($config{DBI}, $config{app_paths}); ``` Then the arguments are used to define a TT² template thus: ``` return Template->new( { INCLUDE_PATH => $_[1]{templates_path}, OUTPUT_PATH => $_[1]{output_path}, CONSTANTS => { database => $_[0]{database}, driver => $_[0]{driver}, user => $_[0]{user}, password => $_[0]{password}, } } ``` The `%config` variable is a hash containing various data structures. The `$config{DBI}` and `$config{app_paths}` elements are hashrefs, and are passed as such. If the subroutine prototypes had been omitted these would have been passed as hashrefs also. The default argument array `@_` is being used in expressions such as `$_[0]{database}` and is unaffected by the prototype. ### Conclusion: - Remove the subroutine prototype used here
davmo self-assigned this 2023-09-17 19:21:18 +00:00
Author
Collaborator

Removed 2023-09-29

Removed 2023-09-29
davmo closed this issue 2023-09-30 22:44:31 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: rho_n/hpr_generator#169
No description provided.