Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (0)

Powered by Vanilla. Made with Bootstrap.
Perl 101 - Part III.
  • rx-
    Posts: 169
    Array variables and working with them

    Example:

    #!/usr/bin/perl -w
    use strict;
    my @array = (\"item\",'item3',4);
    push(@array,\"item5\"); #Adds item5 to @array
    my $var = pop(@array); # Removes the last item and puts it into $var
    my $a = @array; # $a is the number of items in @array
    my $b = \"@array\"; # $b is list of @array items separated by space

    my ($x, $e) = @array; # Assignts the first two items of @array to $x and $e

    my ($xe, @array2) = @array; # $xe is the first item from @array, @array2 is the rest

    print @array.\"\n\";
    print $var.\"\n\";
    print $a.\"\n\";
    print $b.\"\n\n\";
    print $x.\" \".$e;
    print $xe.\" <- \".@array2.\"\n\";


    Output:

    3
    item5
    3
    item item3 4

    item item3item <- 2


    This is everything, in next tutorial ill show you the last type of variables, the hash variables, and then well finally go to learning the control procedures!

    Stay tuned, more to come, rx enjoys the ride!

    If you found this tut interesing, please click this LINK
  • chroniccommand
    Posts: 1,389
    Not much explaining huh? Lol.
  • rx-
    Posts: 169
    Everything is explained within the code in comments, theres not much to say about array variables...
  • Xin
    Posts: 3,251
    Good job, creating the perl section now :)
    Xin
  • rx-
    Posts: 169
    alright, thats cool :)