Home >> perlfunctions >>Perl shiftshift is taking the first element of an array (the leftmost part), while the opposite is pop which is taking the last element of array (the rightmost part).my @arr=("a","b",7,8,9);
my $x = shift @arr;
print "$x\n"; # a
print "@arr\n"; # b 7 8 9
guess what will shift @_ do?@_ contains the arguments passed to subroutine. shift will remove the first argument value from @_. An interesting thing suppose you run a perl file via command line and you are passing arguments... like.. $ ./myfile "arg1" "arg2" myfile is a perl file like.. #!/usr/bin/perl use strict; my $a1= shift; my $a2=shift; in above case $a1 will get "arg1" and $a2 will have "$arg2" Perl functions
|
eval List of all perl functions ord perl function : split Perl function: lc
|