Other thread that I read: What does assigning 'shift' to a variable mean?
I also used perldoc -f shift:
shift ARRAY shiftShifts 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
ARRAYis omitted, shifts the@_array within the lexical scope of subroutines and formats, and the@ARGVarray outside of a subroutine and also within the lexical scopes established by theeval STRING,BEGIN {},INIT {},CHECK {},UNITCHECK {}andEND {}constructs.See also
unshift,push, andpop.shiftandunshiftdo the same thing to the left end of an array thatpopandpushdo to the right end.
I understand outside of subroutines, the array is @ARGV, and inside arguments are passed through @_
I've read countless tutorials on how to use the shift function, but it's always about arrays, and how it removes the first element at the beginning of the array and returns it. But I see sometimes
$eg = shift;
~do more things here~
It seems as if nothing is making sense to me, and I feel like I can't continue reading more until I understand how this works as it's a "basic building block" to the language.
I'm not quite sure if an example of code is needed, as I believe the same principles apply to all programs that use shift. But if wrong I can provide some examples of code.