VBScript or Perl?
Subject:   More considerations
Date:   2003-12-31 02:08:28
From:   anonymous2
Response to: More considerations

"all JScript arrays are hashes: an array with numeric keys can have string keys added, and all keys can be iterated via the loop. As Perl programmers already know, native hash support allows arbitrarily complex data structures to be built quite easily."

Actually, JScript (ECMAScript) support of associative arrays is not very useful. You cannot get as the keys (indices) and let's say sort them, as you can in Perl. This prevents popular data-structures, such as frequency hashes.

For example this functionality of Perl would be quite impossible under Perl.

foreach $key (sort {$a <=> $b} keys %hash) {
printf "%s %s", $hash{$key} $key

However, this could be emulated in JScript (or any other language) using array of an array.

Another nice thing about Perl, not found in other languages is list/array slicing, such as this:

foreach $line (<FILE>) {
my ($empno, $name, $salary) = (split /,/)[0,2,4];

The above slices out the 1st, 3rd, and 5th elements of a CSV file and stores them into local variables called empno, name, and salary. In JScript, this gets a little ugly, and in other languages it gets uglier.

- Joaquin Menchaca

1 to 1 of 1
  1. More considerations
    2004-01-06 08:14:11  brianiac [View]

1 to 1 of 1