Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284318
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:08:28+00:00 2026-05-17T20:08:28+00:00

In the linked SO answer , Eric illustrates a way to call a subroutine,

  • 0

In the linked SO answer, Eric illustrates a way to call a subroutine, which accepts arrays by reference as arguments, and use the prototypes to allow the caller code to pass the array names without using reference operator \@; the way built-ins like push @array, $value do.

# Original code:
sub Hello { my ($x_ref, $y_ref) = @_; ...}
Hello(\@x, \@y);

# Same thing using array ref prototype:
sub Hello (\@\@$) {...}
Hello(@x, @y);

My question is, is this considered to be a Best Practice? And what are the guidelines on the pattern’s use?

It seems like this pattern should either be used ONLY for built-ins, or for 100% of subroutines that accept array arguments in all of your code.

Otherwise code maintenance and use of your subs becomes fragile since the developer never knows whether a particular sub, when called, should be forced to reference an array or not.

An additional point of fragility is that you become confused between doing such calls and legitimately using two arrays combined into one using a comma operator.

On the positive side, using the pattern prevents the “forgot to reference the array” bugs, and makes the code calling the subroutines somewhat more readable.

P.S. I don’t have Conway’s book handy and don’t recall if he ever discussed the topic, to pre-empt RTFB responses.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:08:29+00:00Added an answer on May 17, 2026 at 8:08 pm

    Let’s ask Perl::Critic:

    echo "use strict; sub Hello (\@\@$) {...}" | perlcritic
    Subroutine prototypes used at line 1, column 1.  See page 194 of PBP.  (Severity: 5)
    

    Yeah, that would be a no.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For a simple linked list in which random access to list elements is not
Does anybody want to answer my question linked here how-to-pass-a-typed-collection-from-clojure-to-java , by providing a
If the answer is yes then how would ASP.NET MVC find out that which
According to this answer , the intended way to include non-header-only parts of Boost
I have a linked list that I want to sort part of, eg: std::sort(someIterator,
What is a doubly linked list's remove method?
I followed the commonly-linked tip for reducing an application to the system tray :
I created a Linked List, with insert, search and remove functions. I also created
Jeff's recent article linked to a time management example of the First Fit Decreasing
I need to add linked buttons in the code-behind based on a DataSet that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.