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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:42:10+00:00 2026-05-24T19:42:10+00:00

I have the following code: my @array = (‘a’, ‘b’, ‘c’); my $region =

  • 0

I have the following code:

my @array = ('a', 'b', 'c');

my $region = \@array;  # Returns an array reference
my $Value = ${@{$region}}[3];   

I am using strict;

This code passed smoothly in Perl v5.8.6, and now that I installed v5.10.1, I get a runtime error:

Can’t use string (“4”) as an ARRAY ref while “strict refs” in use at …

I changed the code to the following, and that solved the issue:

my @array = ('a', 'b', 'c');

my $region = \@Array;
my @List = @{$region};
my $Value = $List[3];   

my question is, what’s wrong with the previous way? What has changed between these two versions?
What am I missing here?

Thanks,
Gal

  • 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-24T19:42:11+00:00Added an answer on May 24, 2026 at 7:42 pm

    ${@{$region}}[3] was never the correct way to access an arrayref. I’m not quite sure what it does mean, and I don’t think Perl is either (hence the different behavior in different versions of Perl).

    The correct ways are explained in perlref:

    my $Value = ${$region}[3]; # This works with any expression returning an arrayref
    my $Value = $$region[3];   # Since $region is a simple scalar variable,
                               # the braces are optional
    my $Value = $region->[3];  # This is the way I would do it
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have following code for allocation two dimensional array #include <iostream> using namespace std;
I have the following code that populates an array (this is within a loop):
I have the following code in Python using Numpy: p = np.diag(1.0 / np.array(x))
I have the following code: $selectColumns= array('user_id.user_email', 'user_details.first_name', 'user_details.last_name', 'user_details.zip', 'user_details.store_id'); $result = $handle->select()->from('user_id')
In php, if you have the following code: $map = array( first => 1,
I have following code: $telnums = array(10, 20, 30); $obj = new StdClass(); $obj->telnums
currently I have following code: home.php <form name='myformname' id='myformid'> <input type='text' name='mytext1' value='abc'> <input
I have the following code which uses an array to write the result to
I have the following code in a CakePHP Controller: var $searchCondition = array( 'Item.date
I have the following code: $string = '[url]http://google.com[/url]'; $bbreplace = array ('/\[url\](.+?)\[\/url\]/'); $bbreplacements =

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.