should a subroutine do one thing and one thing well rather than trying to combine both subroutines into one because of the common code between them
Why not both? :) You don't show us an example of the calling code, but it sounds like get_ticket could call "do_request", which returns the data structure, but get_ticket could extract just the ticket ID (scalar) and return that:
sub get_ticket { my $data = do_request(@_); if ($data) { return $data->{ticket_ID}; } return; # error? }
As for variable names ... I like to keep my functions in other namespaces - put all your REST calls into a single module, and then the fact the names look the same wouldn't really matter, and having them have the same names can sometimes be an advantage.
In reply to Re: subroutine and good practices
by Tanktalus
in thread subroutine and good practices
by jmsnet
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |