Using Perl


  1. Check the Perl Help Pages.

  2. Apply for a UND Engineering Linux Account.

  3. Use VPN (Virtual Private Network) to connect to the UND networks.
  4. You may not need to do this if you are on campus.

  5. Log in to the Linux server undcemcs02.und.edu .

  6. Create a Perl script such as Example.pl:

  7. #!/usr/bin/perl
    # Perl program to illustrate iteration through an array
    
    # array creation
    @arr = ( 11, 22, 33, 44, 55 );
    
    # Iterating through the range
    print( "Iterating through range:\n" );
    
    # size of array
    $len = @arr;
    	
    for ( $b = 0; $b < $len; $b = $b + 1 ) {
      print "\@arr[$b] = $arr[$b]\n";
    }
    
    # Iterating through loops
    print( "\nIterating through loops:\n" );
    
    # foreach loop
    foreach $a ( @arr ) { print "$a "; }



  8. Interpret the script.
  9. For example,
       shell> /usr/bin/perl  Example.pl    
    where the Perl interpreter is located at
       shell>