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 >> perldatatypes >>

Perl Data Types

  • Scalar data types
  • lists
  • Arrays
  • Hashes
  •  

    Perl special variables

    These are predefined variables in perl like
    $? : The status returned by the last pipe close, backtick (`` ) command, successful call to wait() or waitpid(), or from the system() operator. learn more

    Summary

  • Scalar variables are prepended with the symbol $. For array and hash variables, the symbols are @ and % respectively.
  • Scalar variables can be assigned a value by using the assignment operator =. A variable holds the value undef by default.
  • Variable names are case-sensitive. They should start with an alphabet or an underscore character ( ). Subsequent characters may be decimal digits as well. Variables whose names not conforming to this nomenclature are predened by Perl and serve special purposes.
  • Variable substitution means variables embedded in a double-quoted string will be substituted by their respective values at the instant the string is evaluated.
  • The substr() function extracts a sequence of characters from a given string.
  • The length() function returns the number of characters in a given string.
  • A list is an ordered set of scalar values. An array is a list associated with a name.
  • An array may be created by assigning a list to an array variable.
  • Nested lists are merged to form a single list when the list is evaluated, with null lists removed.
  • The reverse() function returns a list whose items are identical to the input list except the items are arranged in reverse order.
  • The push() function may be used to append a list of items to the end of an array.
  • The unshift() function prepends a list of items to the beginning of an array.
  • The subscript operator []can be used to access a subset of elements in a list or an array.
  • The pop() and shift() functions may be used to remove an item from an array. pop() removes the last item while shift() removes the rst item.
  • splice() is a general purpose function to add or remove array elements.
  • join() concatenates a list of scalars into a string, inserting a string in between.
  • map() executes a given code block for each list element, and the results evaluated are combined to form an array.
  • Searching an array is not efcient. A hash should be used instead.
  • A hash may be initialized by assigning it a list, whose elements are treated as a list of key-value pairs.
  • To refer to a hash element, use curly braces with the key in between.
  • The delete() function may be used to remove a key-value pair from a hash.
  • You may use the exists() function

    Perl functions

    scalars and strings

    lc
    ord

    regex (regular expressions)

    arrays

    shift
    split

    More..

    eval
  • Share |

    Perl @ARGV %ENV
    Perl Arrays
    Perl Hash
    Perl list
    Perl references
    Perl Scalar data types
    Perl Special Variables

    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