Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL unshift Function



Syntax

unshift ARRAY, LIST


Definition and Usage

Places the elements from LIST, in order, at the beginning of ARRAY. This is opposite function to shift().

Return Value

  • Number of new elements in ARRAY.

Example

#!/usr/bin/perl -w

@array  = ( 1, 2, 3, 4);

print "Value of array is @array\n" ;

unshift( @array, 20, 30, 40 );

print "Now value of array is @array\n" ;

It will produce following results:

Value of array is 1 2 3 4
Now value of array is 20 30 40 1 2 3 4


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names