Perl Tutorial : Perl data types
Perl Tutorial : Perl Operators
Perl Tutorial : Perl loops
Perl Tutorial : Perl Conditionals
Perl Tutorial : Perl Subroutines
Perl Tutorial : Perl regex
Perl Tutorial : Perl Files
Perl Tutorial : Perl & Databases
Perl Tutorial : Perl OOPs
Perl Tutorial : Perl signals
Perl Tutorial : Perl threads
Perl Tutorial : Perl Debugging

Introcution to Perl CGI

Introduction to modperl
Home >> perlfunctions >>

Perl shift

shift 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

scalars and strings

lc
ord

regex (regular expressions)

arrays

shift
split

More..

eval
Share |

eval
List of all perl functions
ord
perl function : split
Perl function: lc

Perl examples

  • How to use Data::Dumper?
  • How to parse config file?
  • Include external module in perl..
  • Download perl

    download stable version of perl
    Perl 5.10.1
    Perl interview Questions
    sed tutorial
    awk tutorial

    Join us on Google Groups

    Subscribe to perl
    Email:
    Visit this group
    Perl Jobs


    privacy | sitemap | disclaim | contact us
    © 2009 perlhome.com