Tuesday, August 15, 2017

Array basics perl

Define an array (say fred) with elements 1 2 and 3.
Define another array (say barney) with elements 4 5 and 6.
Now change the array barney as (4,5,1,2,3,6) using fred.
Put number 8 before all the existing elements of barney.
So barney becomes (8,4,5,1,2,3,6)
Now add a word "last" to the array's barney.
So barney becomes (8,4,5,1,2,3,6,last)
Now assign first three values of barney into 3 different variables.
a-8, b=4 and c=5
swap a and b
Assign the value a into another variable d and, rest of the variables
into another array fred.
d=4 and fred(8,9)
Remove first element of fred into a variable e.

No comments:

Post a Comment