TIP: Click on subject to list as thread! ANSI
echo: st_prog
to: Ron Hunter
from: Evan Langlois of 1:124/7028.0
date: 1996-01-04 11:56:12
subject: Re: PERL?

 RH> Faster than WHICH Basic?  Run it against GFA and HiSoft and let me know.
 RH> Ron

 BASIC just doesn't have the same features that PERL has.  
 First, GFA is so buggy, I'd hate to try and make even a simple
 program with it.  Second, features I use daily in perl don't
 exist in GFA, such as regular expressions or associative arrays.

 Trying to duplicate an associate array (a fast hashing algorythm)
 in GFA is gonna be tough.  Also remember that PERL is compiled
 at run-time into machine code - which will generally run faster
 than most p-code/byte-code/etc compiles.  

 Since I don't have GFA or HiSoft, I can't really run your test.
 However, here is a script out of the 'Camel Book' - the instructional
 book for Perl titled Programming PERL.  It takes a filename on the
 command line, or will read from standard input, a colon separated
 data file, such as :

------------------------8<-----[cut here]-------8<----------------------
Sheep:14023:Lightning:0.29:256
Camels:5972:Chaldeans:3.79:1279
Oxen:2016:Sabeans:4.95:1008
Donkeys:1001:Sabeans:0.99:1001
Sons:7:Tornadoes:22.00:13
Daughters:3:Tornadoes:19.95:37
--------------------8<----[end of data file]---------8<----------------


Now, parse that data and come up with the following output :



                                Job's Stuff, Inc.
  Beastie      Nose   Insured         Premium      Servants       Total Est.
  Name        Count   Against       Each    Total                 Yearly Cost
  -------     -----   -----------   ----  -------  --------       -----------
  Sheep       14023   Lightning     0.29  4066.67       256          70626.67
  Camels       5972   Chaldeans     3.79 22633.88      1279         355173.88
  Oxen         2016   Sabeans       4.95  9979.20      1008         272059.20
  Donkeys      1001   Sabeans       0.99   990.99      1001         261250.99
  Sons            7   Tornadoes    22.00   154.00        13           3534.00
  Daughters       3   Tornadoes    19.95    59.85        37           9679.85




Here's the code
-----------8<---------[cut code here]------------------8<-------------
#!/usr/bin/perl

$ANNUAL_PAY_RATE = 52 * 5;              # That's 5 shekels per week

while () {

    ($beastie, $noses, $hazard, $premium, $servants)
                = split (/:/, $_);

    $totprem = $premium * $noses;
    $cost = $totprem + $servants * $ANNUAL_PAY_RATE;

    # write formatted record to STDOUT

    write;
}
exit;

format STDOUT_TOP =
                                Job's Stuff, Inc.
  Beastie     Nose  Insured       Premium    Servants    Total Est.
  Name       Count  Against   Each   Total               Yearly Cost
  -------    -----  -------   ---- -------   --------    -----------
.

format STDOUT =
  @>>>>>     @#######.##
.


----------------8<---------[ end of code ]------------8<---------------

In this example, if the code file were named 'mydb' and the data file
name mydata, on a Unix command line, you would simply type :

mydb mydata

And the above output would be displayed immediately.  This also works
under MiNT, with DOS you'd have to change the #!/usr/bin/perl to 
something a bit more complicated and the filename for the code would
end in bat.  Under standard TOS 1.x you'd double-click PERL.TTP and
enter 'mydb mydata' in the TTP box.  Under NEWDESK, you can have a .PL
extension associated with PERL.TTP and then drag 'mydata' onto 'mydb.pl'.

Would like to go for a more CPU intensive test?  I think the above example
illustrates some of the better features of PERL.  I think it has many
strengths over BASIC, including speed, and I think it makes a good
addition to any programmers toolbox.







--- Maximus/2 3.01

[+/178 of 200/107 Mins] = * FIDO: ST_PROG =: Next...
* Origin: Wylie Connection 33.6K USR V34+ DS 214-442-0388 (1:124/7028)

SOURCE: sfhq

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.