Help for this page

Select Code to Download


  1. or download this
    for(my $i = 0; $i < @filecontents; $i++)
    {
    ...
        # 
        @line = split(/\,/, $filecontents[$i]);
        # XXX           ^------ do you really mean comma?
    
  2. or download this
        # [] constructs an anonymous array, so we use that.
        # several ways to do it - choose any (not all :-)
    ...
        # the array @matrix
        push(@matrix, [split(/\s+/, $filecontents[$i])]); 
    }
    
  3. or download this
    my @matrix;
    while (<INPUT>) {
        chomp; # you forgot that - remove trailing newline char
        push(@matrix, [split]);
    }
    
  4. or download this
    #!/usr/bin/perl
    
    ...
        chomp; # you forgot that - remove trailing newline char
        push(@matrix, [split]);
    }
    
  5. or download this
    $#ARGV = 0;  # @ARGV now holds only one element (the first at index 0)
    
  6. or download this
    print $matrix[7]->[4],"\n";