What is the difference it seems push and pop work just like unshift and shift respectively .

To find out if the effect of push differs from the effect of unshift, try them both and see.

#!/usr/bin/perl
use strict;
use warnings;

my @pusharray = ('original', 'contents');
push @pusharray, $_ foreach(1..10);
print "array contains @pusharray\n";

my @unshiftarray = ('original', 'contents');
unshift @unshiftarray, $_ foreach(1..10);
print "array contains @unshiftarray\n";

Output:

array contains original contents 1 2 3 4 5 6 7 8 9 10
array contains 10 9 8 7 6 5 4 3 2 1 original contents
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.