Perl Home
PERL Functions
© 2011 TutorialsPoint.COM
|
PERL shift Function
Syntax
Definition and Usage
Returns the first value in an array, deleting it and shifting the elements of the array list to the left by one. If ARRAY is not specified, shifts the @_ array within a subroutine, or @ARGV otherwise. shift is essentially identical to pop, except values are taken from the start of the array instead of the end.
Return Value
Example
Try out following example:
#!/usr/bin/perl
@array = (1..5);
while ($element = shift(@array)) {
print("$element - ");
}
print("The End\n");
|
It will produces following result.
1 - 2 - 3 - 4 - 5 - The End
|
|

|
|
|