Variables: String, array, map summary
Bash variables are untyped, they can be assigned with many types of data. 1. When assigning values to bash variables, make sure the variables are naked. 2. However when bash variables are referenced, a '$' in front is needed. Perl variables are typed in comparison, and alway need a prefix($, @ or %) no matter whether they are referenced or assigned with values. perl have three basic types: 1. Scalar type, starting with $ such as $myscalar, represents a number or a string of text. 2. Arrays type, starting with @ sign as @myarray, are ordered list of scalar. 3. Hashes type, starting with % sign as %mymap, are unordered list of key value pair. Python variables don't use any prefix in front, no '$,', no '@' or anything else, they are alway naked. python's main built-in data types are: 1. Numbers type: including int, long, float, complex. 2. Iterables type 3. Sequence: strings, unicode, lists, tuples. 4. Set: set, frozenset. 5. Mapping(dict)
Tasks: 1.Define three variables for string, array and map respectively. 2.Print the string variable 3.Print the array variable 4.Print the map variable
Bash | Perl | Python |
---|---|---|
|
|
|