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

  • Home
  • SEARCH
  • 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

I've been linked in the past to this response to a similar question on
As a followup on this answer : Specified javascript does work in case of
I'm intrigued by this answer from another SO thread, and I was hoping someone
In my previous question I was looking for a way of evaulating complex mathematical
This answer hit a nerve with me on something I have never understood with
If you have an interesting story to share, please post an answer , but
I'm writting a simple prototype front end using a GridView that is populated via
I'm looking for the best approach to share types (the actual classes, not proxies)
I am trying to see if an option was selected in a selectbox and
This is a follow-up to an earlier question I posted on EF4 entity keys

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.