-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
hash.mon
58 lines (46 loc) · 912 Bytes
/
hash.mon
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// Dump the hash specified
//
function dump( hash ) {
let k = keys(hash);
puts("\tHash has ", len( k) , " keys.\n" );
let i = 0;
for( i < len(k )) {
// Show the name / type / value
puts( "\tEntry has key:" , k[i] ,
" (type:", type(k[i]), ")",
" with value:", h[k[i]], "\n");
i++;
}
}
//
// Here is a sample hash
//
let h = { "Steve": "Kemp" , "Moi": 7, 3.14:"pi?"};
//
// Show it.
//
puts( "The original hash:\n" );
dump( h );
//
// Add a new key
//
let h = set(h, "Updated", "Value" );
//
// Show it
//
puts( "After adding a new key:\n" );
dump( h );
//
// Delete two keys
//
let h = delete(h, "Moi" );
let h = delete(h, 3.14 );
puts( "After deleting two keys:\n" );
dump( h );
puts( "Running command: /bin/ls\n");
let h = `/bin/ls / /fdsf`;
dump( h);
puts( "Running via bash:\n");
let h = `/bin/sh -c "/bin/ls /etc"`;
dump( h);