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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:46:16+00:00 2026-05-29T11:46:16+00:00

I am trying to use the following perl function, but I am not very

  • 0

I am trying to use the following perl function, but I am not very clear about three points:

sub inittwiddle { 
    my ($m,$n,$aref) = @_; 
    my $i; 
    $$aref[0] = $n+1; 
    for ($i=1; $i != $n-$m+1; $i++) { 
       $$aref[$i] = 0; 
    } 
    while($i != $n+1) { 
       $$aref[$i] = $i+$m-$n; 
       $i++; 
    } 
    $$aref[$n+1] = -2; 
    $$aref[1] = 1 if ( $m == 0 ); 
} 

First, what does my ($m,$n,$aref) = @_; stand for?

Second, how to understand the $$ for sth like $$aref[0] = $n+1;

And this function was invoked as inittwiddle($M,$N,\@p); what does \@p stand for?

  • 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-29T11:46:16+00:00Added an answer on May 29, 2026 at 11:46 am
    1. @_ is the list of arguments passed to the function. By doing my ($m,$n,$aref) = @_; you’re assigning $_[0] to $m, $_[1] to $n, and $_[2] to $aref.

    2. $aref is a scalar value holding a reference to an array. To refer to elements within the array you can either access them via $aref->[0] (this is more idiomatic), or by dereferencing the array reference. By adding a @ to the front, you’d refer to the array (i.e. @$aref). However, you want the first element in the array, which is a scalar, so it’s obtained by $$aref[0]. Adding brackets (${$aref}[0]) or using the arrow notation ($aref->[0]) clarifies this a little.

    3. \@p is a reference to the array @p. Since your function takes a scalar as the third argument, you have to pass in a scalar. \@p is such. When you pass an array reference into a function like this, it’s important to note that any changes to the array (such as doing $$aref[0] = $n+1) are changes to the original array. If you want to avoid this, you would dereference the array into a temporary one, possibly by doing my @tmparr = @$aref; within the function.

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

Sidebar

Related Questions

I am trying to use threads in Perl, but I get the following errors
I am trying to use the following script in asp.net: <script language=javascript type=text/javascript> function
I'm trying to use the following code (poorly written, but it's just a proof
I'm trying to use a simple perl one-liner on the following input: @F7##########0/1 C4CTA6GCAAC56G67CTCA99C
I'm trying to execute the following script: #!/usr/bin/perl -w use strict; use DBI; my
I am trying to use the following code, which I have not been able
I'm trying to use quotemeta in Perl. The following is the code with the
Trying to use the following demo example, using the 80px x 80px snap to
I am trying to use the following jcache-ehcache library to as a wrapper so
I am trying to use the following code, to display $formcode, which is 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.