Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This shouldn't be confusing at all. The unshift() function in JavaScript, Perl's sister language, works the same way. When you want to unshift more than one item at a time, it grabs them as one and inserts them in front of the array in the same order as you put them. This is useful, because if we consider a real-life scenario where you want to pack some data, and the First name must come first, followed by Last Name and then the middle name, you could do something like : unshift(@PACKAGE, @NAMES); then the address, where the first element of address holds the house number, followed by street, city, state, zip code, in that order, the unshift method will not mess up the order. It will simply insert these items into the array just the way they appear in the other array: unshift(@PACKAGE, @ADDRESS); unshift(@PACKAGE, @DELIVERY_DATE_SELECTED); So, let's say you have a DATE array which contains the year first, followed by month and day. If you unshift that, the order will remain the same in the array, which is logical and that's how it should work.

In reply to Re: I am confused by a "Learning Perl" sample showing "unshift" by harangzsolt33
in thread I am confused by a "Learning Perl" sample showing "unshift" by KenAndrews

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-19 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found