Twitter Updates

    follow me on Twitter

    Friday, August 14, 2009

    Perl Hello script


    #! /usr/bin/env perl

    use strict;
    use warnings;

    print "Hello World!\n";
    my $string = "Cloud";
    my $number = 9;
    my $lil_float = 2e-12;
    print '"$string $number": ', "$string $number\n";
    print '$lil_float: ', $lil_float, "\n";
    print '$lil_float+1: ', $lil_float+1, "\n";
    my @books = ( "Pride and Prejudice",
    "Bambi: Eine Lebensgeschichte aus dem Walde",
    "To Kill a Mockingbird",
    "The Adventures of Huckleberry Finn",
    "Oliver Twist",
    "Middlemarch",
    "Le Petit Prince"
    );
    my %auth_book = ( 'Austen' => "Pride and Prejudice",
    'Salten' => "Bambi: Eine Lebensgeschichte aus dem Walde",
    'Lee' => "To Kill a Mockingbird",
    'Twain' => "The Adventures of Huckleberry Finn",
    'Dickens' => "Oliver Twist",
    'Eliot' => "Middlemarch",
    'Saint Expuery' => "Le Petit Prince"
    );
    my $bk_ref_ref = [ \@books, \%auth_book ];
    print '@books: ', @books,"\n";
    print '%auth_book: ', %auth_book,"\n";
    print '"@books": ', "@books\n";
    print '"%auth_book": ', "%auth_book\n";
    print '"@books[2,3]": ', "@books[2,3]\n";
    print '"@auth_book{\'Saint Expuery\', \'Lee\'}": ',
    "@auth_book{'Saint Expuery', 'Lee'}\n";
    print '$bk_ref_ref: ', "$bk_ref_ref\n";
    print '"@$bk_ref_ref": ', "@$bk_ref_ref\n";
    print '"@{@$bk_ref_ref[0]}": ', "@{@$bk_ref_ref[0]}\n";
    print '"$bk_ref_ref->[0]->[0]": ', "$bk_ref_ref->[0]->[0]\n";
    print '"@{$$bk_ref_ref[1]}{\'Eliot\', \'Twain\'}": ',
    "@{$$bk_ref_ref[1]}{'Eliot','Twain'}\n";

    No comments: