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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:06:58+00:00 2026-06-13T14:06:58+00:00

I have declared an array, and a reference to that array like this: –

  • 0

I have declared an array, and a reference to that array like this: –

my @array = (1, 2, 3, 4);
my $aref = \@array;

Now, I’m trying to reverse the array, using the array name and the reference name.

print reverse @array, "\n";
print reverse @{$aref}, "\n";

This is working fine, and printing the reversed array in both the cases: –

4321
4321

However, if I try to print the reverse in the same line, its giving me a strange result: –

print reverse @array, reverse @{$aref}, "\n";

Now, I got this output: –

1234
4321

and if I add a newline in between: –

print reverse @array, "\n", reverse @{$aref}, "\n";

I got this output: –

1234

4321

So, there are two problems as you can see: –

  • 1st, The array is not getting reversed for using the name
  • 2nd, there is an extra newline getting printed between the two reversed array.

I can’t understand this behaviour, why this could be happening. Also I went through the documentation of the function reverse to check whether there is mentioned any where about this behaviour, but I didn’t dine any. Can anyone explain what’s happening here?

  • 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-13T14:07:00+00:00Added an answer on June 13, 2026 at 2:07 pm
    reverse @digits, reverse @$digits, "\n"
    

    means

    reverse(@digits, reverse(@$digits, "\n"))
    

    You want

    reverse(@digits), reverse(@$digits), "\n"
    

    or simply

    reverse(@$digits, @digits), "\n"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I have declared a variable like this @{ int i = 1; } Now,
I have declared a DLL import in my C# program that looks like this:
I have a variable length array of strings declared in javascript that contains Dungeons
I have declared std::priority_queue like this. priority_queue < Aircraft, vector<Aircraft>, less<Aircraft> > *q; And
I have declared an array in the form: var refs = { 'EE810': Presence
I have a C++ array declared as mentioned below: CString carray[] = { A,
I have a project that requires the following. Four arrays will be declared in
I am using a class called BigNumDesc that represents a number. I have a
I have been trying to use 2D array as a parameter to a constructor

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.