Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. PERL: Inserting element into array

PERL: Inserting element into array

Scheduled Pinned Locked Moved Web Development
questionperldatabasedata-structureshelp
4 Posts 3 Posters 11 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lnong
    wrote on last edited by
    #1

    Lets say I have a 5-element array such as @array = (1,2,3,4,5). Is there a function or some quick way insert element "100" into the 3rd position such as (1,2,100,3,4,5)? I cannot find a way to use an index to reference an array element. Another example: If I have an array with (1,2,100,6,4,100,3,100), how can I quickly sort it to (1,2,100,100,100, 6,4,3)? Please help. Thanks.

    F 1 Reply Last reply
    0
    • L lnong

      Lets say I have a 5-element array such as @array = (1,2,3,4,5). Is there a function or some quick way insert element "100" into the 3rd position such as (1,2,100,3,4,5)? I cannot find a way to use an index to reference an array element. Another example: If I have an array with (1,2,100,6,4,100,3,100), how can I quickly sort it to (1,2,100,100,100, 6,4,3)? Please help. Thanks.

      F Offline
      F Offline
      Florin Ochiana
      wrote on last edited by
      #2

      Hi, Check http://www-2.cs.cmu.edu/People/rgs/pl-exp-arr.html You'll find all the functions you can use for arrays. Have fun! :) ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.

      J 1 Reply Last reply
      0
      • F Florin Ochiana

        Hi, Check http://www-2.cs.cmu.edu/People/rgs/pl-exp-arr.html You'll find all the functions you can use for arrays. Have fun! :) ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.

        J Offline
        J Offline
        J Dunlap
        wrote on last edited by
        #3

        Florin Ochiana wrote: We are what we repeatedly do. Excellence, then, is not an act, but a habit. Nice sig! :-D

        "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
        "You must be the change you wish to see in the world." - Mahatma Gandhi

        F 1 Reply Last reply
        0
        • J J Dunlap

          Florin Ochiana wrote: We are what we repeatedly do. Excellence, then, is not an act, but a habit. Nice sig! :-D

          "Blessed are the peacemakers, for they shall be called sons of God." - Jesus
          "You must be the change you wish to see in the world." - Mahatma Gandhi

          F Offline
          F Offline
          Florin Ochiana
          wrote on last edited by
          #4

          Aristotle said it first :) ----- We are what we repeatedly do. Excellence, then, is not an act, but a habit.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups