Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Assigning Shift to a variable

Hi,
I am in the process of learning perl. I came through a piece of code where the shift operator is being assigned to a variable. The code is something like this:

my ($var1) = shift;

I am not quite able to understand what exactly happens here and how this work? Can someone please explain?

Thanks
0
akila76
Asked:
akila76
1 Solution
 
ozoCommented:
perldoc -f shift
       shift ARRAY

       shift   Shifts the first value of the array off and
               returns it, shortening the array by 1 and moving
               everything down.  If there are no elements in the
               array, returns the undefined value.  If ARRAY is
               omitted, shifts the `@_' array within the lexical
               scope of subroutines and formats, and the `@ARGV'
               array at file scopes or within the lexical scopes
               established by the `eval ''', `BEGIN {}', `INIT
               {}', `CHECK {}', and `END {}' constructs.
0
 
akila76Author Commented:
Thanks a lot
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now