ASPL User Guide v 1.00
© 2025 Bassem W. Jamaleddine


9-2

   Executing ASPL Group Operations from Other Languages

Since it is possible to pipe STDIN to the ASPL interpreter then one can use ASPL with other programming languages. ASPL reads the STDIN first line and determines if it is a shebang giving priority to its arguments (overriding any argument should it be specified prior to the -STDIN pipe). The following scripts show how to call ASPL from PERL scripts.

■ Script to Compare Jar Files

Comparing many Jar files that have the same name but they come from different distributions. The Perl script jarcompare.pl creates an ASPL script to compare many Jar files, then presents the script to the ASPL interpreter via STDIN to process the script.

Line 15 loops over each argument supposed to be a the fully specified Jar file, and line 16 checks if the file is readable. Line 18 makes the ASPL expression: globing the Jar file with ggjar() GG-function, assigning it to a set variable, and concatenates the expression to a string. Line 9 memorizes the set variables in an ordered list @jars. Line 21 concatenates the final expressions of the script before it is being piped to the STDIN of ASPL (lines 28 and 29). Line 28 starts the ASPL interpreter in a child process that reads the script presented as a string to ASPL STDIN.

For examples on running the script, refer to the ASPL Manual.

 -LIS- Listing. 9.2.1   [LISTING jarcompare.pl][ASPL Script jarcompare.pl]
(raw text)
1.     #!/usr/bin/perl
2.     
3.     use strict;
4.     
5.     # jarcompare.pl compares two or many Jar files:
6.     #   jarcompare.pl file1 file2 ..
7.     
8.     usage() unless @ARGV > 1;
9.     sub usage { print join "",<DATA>; exit; }
10.    
11.    my $interpreter = "aspl -groupingclass POSIX -wsname TRANSIENT -singlepass";
12.    my $s = "displayoff\n";
13.    
14.    my @jars;
15.    for (my $i=0; $i<@ARGV; $i++) {
16.        die "CANNOT READ THE JARFILE $ARGV[$i]\n" unless -r $ARGV[$i];
17.        # adding aspl variables as jar0 jar1 ..
18.        $s .= "jar$i = ggjar(jarfile,$ARGV[$i],calchksum,1,calentropy,1)\n";
19.        push(@jars,"jar$i");
20.    }
21.    $s .= "
22.    displayon
23.    ks chksum ppdd ffl
24.    gU @jars
25.    sim @jars
26.    ";
27.    
28.    open(ASPL, "| $interpreter -STDIN") or die "ERROR OPENING A PIPE TO aspl: $! 
      \n"; 
29.    print ASPL $s;
30.    close ASPL;
31.    
32.    __END__
33.    
34.       jarcompare.pl must be followed by a list of jar files
35.    
36.         jarcompare.pl  jarfile1  jarfile2  ..
37.    

ASPL(C) 2025 Bassem Jamaleddine