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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:35:35+00:00 2026-06-01T00:35:35+00:00

I am trying to create the subroutine mypush with similar functionality of inbuilt push

  • 0

I am trying to create the subroutine mypush with similar functionality of inbuilt push function, but the below code is not working properly.

    @planets = ('mercury', 'venus', 'earth', 'mars');
    myPush(@planets,"Test");

    sub myPush (\@@) {
         my $ref = shift;
         my @bal = @_;
         print "\@bal :  @bal\nRef : @{$ref}\n";
         #...
    } 
  • 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-01T00:35:36+00:00Added an answer on June 1, 2026 at 12:35 am

    At this line:

        myPush(@planets,"Test");
    

    Perl hasn’t yet seen the prototype, so it can’t apply it. (If you turn on warnings, which you always should, you’ll get a message that main::myPush() called too early to check prototype.)

    You can either create your subroutine before you use it:

        sub myPush (\@@) {
             my $ref = shift;
             my @bal = @_;
             print "\@bal :  @bal\nRef : @{$ref}\n";
             #...
        }
    
        @planets = ('mercury', 'venus', 'earth', 'mars');
        myPush(@planets,"Test");
    

    or else at least pre-declare it with its prototype:

        sub myPush (\@@);
    
        @planets = ('mercury', 'venus', 'earth', 'mars');
        myPush(@planets,"Test");
    
        sub myPush (\@@) {
             my $ref = shift;
             my @bal = @_;
             print "\@bal :  @bal\nRef : @{$ref}\n";
             #...
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying create alert dailog using glade,but its not working .am i doing
I'm trying create a small http proxy service. This is not working so well.
Trying to create a user account in a test. But getting a Object reference
I'm trying create a RCP Application with Eclipse, but I can't get past the
I am trying to create a truth table for the function F=(A&B) XOR (C&D').
I'm trying create this function such that if any key besides any of the
I am trying create a new css for shaping my detailsview. But i couldn't
I'm trying create a simple audio stream server like a concept proof, but I'm
I am trying create my custom Style spinner with help of this site. But
I am trying create a WCF service that leverages the WPF MediaPlayer on the

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.