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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:12:46+00:00 2026-05-17T15:12:46+00:00

This is not generic question. I have asked this question because I’m confused with

  • 0

This is not generic question. I have asked this question because I’m confused with creating Perl arrays.

  1. How do I create or define the Array or hash? What are other ways to do that?
  2. How do I clear a array or hash? What are other ways to do that?
  3. How do I create a array or hash with empty element?
  4. What are the ways to create hash with out values?
  • 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-17T15:12:47+00:00Added an answer on May 17, 2026 at 3:12 pm

    Lexical arrays and hashes are created empty. You can create a new lexical array or hash with my:

    my @array;
    my %hash;
    

    For the most part, you should only be using lexical arrays and hashes, but you can create package arrays and hashes with our:

    our @array;
    our %hash;
    

    @array and %hash may or may not have data in them in this case (if they were previously created, this will not clear their contents). The names of these variables are lexically scoped, but the data is package scoped, so if you say:

    {
        our @a = (1 .. 5);
    }
    {
        our @a;
        print "@a\n";
    }
    

    It will still print "1 2 3 4 5\n".

    There are many ways to clear a hash or array. The most common is to assign an empty list to it:

    @array = ();
    %hash  = ();
    

    You can also use undef to clear a hash or array:

    undef @array;
    undef %hash;
    

    You could also pop, shift, or splice items off of an array:

    pop   @array while @array;
    shift @array while @array;
    
    splice @array, 0, scalar @array;
    

    You can also modify the number of elements in and an array by assigning a number to the $#array form of its name. If you assign a negative value, the array is emptied:

    $#array = -1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No, this is not a question about generics. I have a Factory pattern with
Sorry for this not being a real question, but Sometime back i remember seeing
Under what circumstances would this or would this not be safe? I have a
This is not exactly a programming question, but it's highly related. We are writing
Ok, so, my visual studio is broken. I say this NOT prematurely, as it
$(#dvMyDIV).bind(resize, function(){ alert(Resized); }); or $(#dvMyDIV).resize(function(){ alert(Resized); }); The questions Why is this not
This is not a new topic, but I am curious how everyone is handling
This is not a technical problem, but very annoying. Does anyone know how to
This may not be the correct way to use controllers, but I did notice
This is not yet particularly programing related but, I am very interested in how

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.