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 8044021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:05:47+00:00 2026-06-05T05:05:47+00:00

So I am a beginning Perl programmer. I have been using it for about

  • 0

So I am a beginning Perl programmer. I have been using it for about a month, however only in the last week or so have I been using it for anything other than sysadmin type tasks. In doing so I ran into the following question,

Perl subprocesses are really flexible, and they don’t impose many/any constraints on arguments you pass in. How is it possible to either enforce the number of arguments and/or check whether they’re references, scalars etc etc?

To clarify, here’s what I currently do for Perl subprocesses:

sub mySub{
    ($a, $b) = @_;
    continue and use these methods
 }

But this provides no guarantees about what $a and $b hold. Is there anyway to make sure they contain values, say a reference for $a and a scalar for $b?

Thanks in Advance.

EDIT: When I said scalar for $b I mean containing an integer, and not being a reference to some other datastructure.

  • 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-06-05T05:05:50+00:00Added an answer on June 5, 2026 at 5:05 am

    You can use the Params::Validate module, it provides wide possibilities of checking the argument list.

    In your case, something like

    validate_pos(@_, { type => HASHREF | ARRAYREF }, { type => SCALAR })
    

    would do it (note that it doesn’t have a single type for “ref”). It dies when the parameters don’t match.

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

Sidebar

Related Questions

I'm starting to learn perl, using the Wrox Beginning Perl available on perl.org and
I am using Perl to load some 'macro' files. These macros can, however, be
I have a huge Perl script (1500+ lines) that takes about 8 hours to
Beginning to use perl RegExp.I am using the following RegExp to catch unwanted blank
I have been told that disabling backreferences in perl improves performance (provided you're not
The Perl FAQ entry How do I strip blank space from the beginning/end of
Since beginning to use VB.NET some years ago I have become slowly familiar with
I am in early beginning of learning and deploying Win App using C#, Now
I am a beginning javascript programmer. I am trying to create something similar to
I am new to Perl and I have a problem that's very simple but

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.